I am trying to add an input field on the end of every row in a table I created.
ID: 3764174 • Letter: I
Question
I am trying to add an input field on the end of every row in a table I created. The table was created by pulling data out of a sql database with PHP. The chunk of my code (the PHP portion) that I did to make the table is this:
I tried adding the following line of code to add the input field at the end of each row, however, the result of my attempt only made a line of input boxes along the top of the browser above my table. So I am confused as to how to accomplish this task. If I could get some direction or guidance on how to code this, I would appreciate it!
Explanation / Answer
TRY THIS!!!
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to create table
$sql = "CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";
if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.