I have been looking for a while to update multiple rows in a mysql table and can not find the appropriate was to access the names of the text fields passed when i press submit. To help explain what I am trying to do here is a simplified bit of code:
<html>
<body>
<?php
$db = mysql_connect("host", "user","pass")or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
mysql_select_db("databasename",$db);
if ($submit) {
//here is where i need an appropriate loop to go through each name field
$sql = "UPDATE tablename SET name='$name' WHERE id=$id";
}
$result = mysql_query($sql);
echo "Record updated!<p></a>";
}
printf("<form method=\"post\" action=\"%s\"> \n",$PHP_SELF);
$count=0;
$result = mysql_query("SELECT * FROM tablename",$db);
while ($myrow = mysql_fetch_array($result)) {
$count=$count+1; //count number of rows
printf("<input type=\"Text\" name=\"id%s\" value=\"%s\"> \n", $count, $myrow["id"]);//put id in a text field will change it to hidden
printf("<input type=\"Text\" name=\"name%s\" value=\"%s\"><br> \n", $count, $myrow["name"]); //put name in a text field
}
?>
<input type="Submit" name="submit" value="Enter information"></td></tr>
</form>
</body>
</html>
If this does not make sense im sorry just ask for any clarifications.
Thanks alot
Justin