I am inserting data to mysql and then at the same time retrieving it.
While retrieving i cannot put it to the place where i want.
I want to dispaly the data below the header.
I have a registration form(which is in php) below the header (which is in html) when user submits the registration form at the same time and the same area i want to retrieve all records from the table.I have this code:
While retrieving i cannot put it to the place where i want.
I want to dispaly the data below the header.
I have a registration form(which is in php) below the header (which is in html) when user submits the registration form at the same time and the same area i want to retrieve all records from the table.I have this code:
PHP Code:
if (isset($_POST['submit_registration_x'])){
include "connection.php";
$table_name = "registration";
$sql = "INSERT INTO $table_name (id, name, father_name, gender, address)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[father_name]', '$_POST[gender]', '$_POST[address]')";
$result = @mysql_query($sql, $connection) or die (mysql_error());
$sql = "SELECT * from $table_name";
$result = mysql_query($sql, $connection) or die (mysql_error());
echo "<form method='post' action='student.php' name='student_records'>
<table border='1' cellspacing='4' cellpadding='2' align='center'>
<tr><th>ID</th><th>Name</th><th>Father's Name</th><th>Gender</th><th>Address</th></tr>";
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$name = $row['name'];
$father_name = $row['father_name'];
$gender = $row['gender'];
$address = $row['address'];
echo"<tr><td>$id</td><td>$name</td><td>$father_name</td><td>$gender</td><td>$address</td></tr>";
}
echo "</table></form>";
}
?>
Comment