Hi,
I'm calling data from a mysql db and pumping the data back into a form (i.e. text fields etc) by use of an array so that multiple entries can be updted in one go. My problem is that when I press the update button, only the bottom/last entry in the form gets updated(understandably). How do I get a loop working so that the data from the form gets pumped into the dbase for the right fields. My form looks like so:
******************form**********************************
<?php
session_start();
?>
<link rel="STYLESHEET" type="text/css" href="style.css">
<html>
<body bgcolor="#D9E1F4">
<?php
// open the connection
$conn = mysql_connect("localhost", "", "");
// pick the database to use
mysql_select_db("imperial",$conn);
// create the sql statement
$sql = "SELECT id, sub, vname, vtel from place";
// execute the sql statement
$result = mysql_query($sql, $conn) or die(mysql_error());
// print the table and form with data pumped back into it
print "<form method=\"post\" action=\"changeallprocess.php\"><table cellpadding=5 border=1 width=100% bordercolor=white bgcolor=\"#D9E1F4\">";
// go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$id = $newArray['id'];
$sub = $newArray['sub'];
$vname = $newArray['vname'];
$vtel = $newArray['vtel'];
echo "
<tr>
<td><font size=2 face=\"verdana\">$vname:</td>
<td><input type=\"hidden\" name=\"id\" value=\"$id\">$id</td>
<td><input type=\"text\" name=\"sub" value=\"$sub\"></td>
<td><input type=\"text\" name=\"vtel\" value=\"$vtel\"></td>
</tr>
";
}
print "<td colspan=4 align=\"center\" valign=\"top\"><input type=\"Submit\" name=\"submit\" value=\"Modify Venues\"></td></tr>
</form></table>";
?>
</body>
</html>
Reality is built on a foundation of dreams.
I'm calling data from a mysql db and pumping the data back into a form (i.e. text fields etc) by use of an array so that multiple entries can be updted in one go. My problem is that when I press the update button, only the bottom/last entry in the form gets updated(understandably). How do I get a loop working so that the data from the form gets pumped into the dbase for the right fields. My form looks like so:
******************form**********************************
<?php
session_start();
?>
<link rel="STYLESHEET" type="text/css" href="style.css">
<html>
<body bgcolor="#D9E1F4">
<?php
// open the connection
$conn = mysql_connect("localhost", "", "");
// pick the database to use
mysql_select_db("imperial",$conn);
// create the sql statement
$sql = "SELECT id, sub, vname, vtel from place";
// execute the sql statement
$result = mysql_query($sql, $conn) or die(mysql_error());
// print the table and form with data pumped back into it
print "<form method=\"post\" action=\"changeallprocess.php\"><table cellpadding=5 border=1 width=100% bordercolor=white bgcolor=\"#D9E1F4\">";
// go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$id = $newArray['id'];
$sub = $newArray['sub'];
$vname = $newArray['vname'];
$vtel = $newArray['vtel'];
echo "
<tr>
<td><font size=2 face=\"verdana\">$vname:</td>
<td><input type=\"hidden\" name=\"id\" value=\"$id\">$id</td>
<td><input type=\"text\" name=\"sub" value=\"$sub\"></td>
<td><input type=\"text\" name=\"vtel\" value=\"$vtel\"></td>
</tr>
";
}
print "<td colspan=4 align=\"center\" valign=\"top\"><input type=\"Submit\" name=\"submit\" value=\"Modify Venues\"></td></tr>
</form></table>";
?>
</body>
</html>
Reality is built on a foundation of dreams.