Hey all.
Ok this is so basic but confused. I'm updating the student name in this instance. I'm able to extract the name out of the database, but I cannot update. Any hints as to where i'm going wrong?
<?php
$dbhost = 'localhost';
$dbuser = 'nbsstud1_test1';
$dbpass = 'demon8';
$dbname = 'nbsstud1_testdb';
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);
$msg = " ";
if(!empty($_POST["update"]))
{
mysql_query("UPDATE students SET firstname='".$_POST["firstname"]."' WHERE student_id ='".$_POST["student_id"]."'");
$msg = "Record # ".$_POST["student_id"]." has been successfully updated.";
}
$result = mysql_query("SELECT * FROM students ORDER BY 'student_id', 'firstname'");
echo "<table width='100%' border='0' cellspacing='1' cellpadding='1'>
<tr>
<th>Student Id</th>
<th>Firstname</th>
</tr>";
while($Update = mysql_fetch_assoc($result))
{
echo "<tr>
<form method='post' action='edit.php'>
<td align='center'><input type='text' name='student_id' value='{$Update['student_id']}' readonly style='border:none;background:none;text-align:center;' /></td>
<td align='center'><input type='text' name='firstname' value='{$Update['firstname']}' /></td>
<td colspan='4' align='center'><input type='submit' name='update' value='Update' /></td>
</form>
</tr>";
}
echo "</table><center><div style='width:450px;text-align:center;font-size:20px;font-weight:bold;color:#00f;margin-top:20px;border:1px solid #000;'>$msg</div></center>";
?>