Question: Need a PHP code that has a box to type in that allows the user to put the information through the PHP site to the

Need a PHP code that has a box to type in that allows the user to put the information through the PHP site to the database for the following categories: INT, First name, Last name, Sex. Once injected it needs to echo to the page to show the table of all entries.

The code below is how far I got with it.

MySQL: add a row and query

$link = mysql_connect('stewcraw.dotstermysql.com', 'prof', '3632password');

if (!$link) {

die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully ';

mysql_select_db(jacob_f18);

if ( mysql_query("DROP TABLE Persons") )

{ echo "table dropped ";}

if ( mysql_query("CREATE TABLE Persons (PersonID int, LastName varchar(255), FirstName varchar(255), Sex varchar(255))" ) )

{ echo "created ";}

else

{ echo "create failed ";}

mysql_query("INSERT INTO Persons VALUES(1, 'Smith', 'Jack', 'Male');");

$result = mysql_query("SELECT * FROM Persons;");

// $result is a sequence of rows, each row is an array of fields of the output

while ($row = mysql_fetch_row($result)){

echo $row[0] .' '. $row[1] .' '. $row[2].' '. $row[3].' '. $row[4] . ' ';

}

?>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!