Howdy,
I do a Select * from Table and then lay them out in an html table and want the user to choose one of those records to edit.
I am trying to do this by sending the integer $id to the next page and then Select * from Table Where ID = $sid but it always sends the last ID (which makes sense because that was the last value written into that variable.)
1) Is there a way to make the hidden var of each row pass its unique value rather than the last value written into the var?
Here's the code for list.php:
$sql = "SELECT * FROM songs";
$result = mysql_query($sql)
or die("SELECT Error: ".mysql_error());
print "<form action='edit.php' method='POST'>\n";
print "<table width=400 border=1>\n";
print "<tr>\n";
while ($get_info = mysql_fetch_row($result))
{
$sid = $get_info[0];
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "\t<td><input type='hidden' value=$sid name='sid'>\n";
print "\t<input type='submit' value='Edit' name='submit'></td>";
}
and question 2) $sid = $get_info[0]; works but $sid = $get_info[songid]; does not work. Why? for some reason I couldn't get this to work with the field name and I tried it with single and double quotes around the field name