Changed some things around. Still can't get $rest_id and which ad boxes have been checked to update to my database. Any help is greatly appreciated.
$selected_cities = implode("' or '", array_unique($names));
echo "<form name='mark_sold' action='mark_sold.php' enctype='multipart/form-data' method='post'><table width='1100' border='1'><tr><td><h2>Spot 1</h2>";
$Get_City1 = mysql_query("SELECT rest_id, rest_name, city, ad_space1 FROM restaurant_info WHERE state = '$state1' AND city = ('$selected_cities') ORDER BY rest_id");
while ($got_city1 = mysql_fetch_array($Get_City1)) {
$rest_id = $got_city1['rest_id'];
$rest_name = $got_city1['rest_name'];
$city = $got_city1['city'];
$ad1 = $got_city1['ad_space1'];
if($ad1 == '1'){
$is_sold1 = "<font color='red'>sold</font>";
}else{
$is_sold1 = "<font color='green'>available</font><input name='ad1[$rest_id]' id='ad1' type='checkbox' value='1[$rest_id]'/>";
}
echo $rest_name." in ".$city." is ".$is_sold1."<br />";
}
echo "</td><td><h2>Spot 2</h2>";
$Get_City2 = mysql_query("SELECT rest_id, rest_name, city, ad_space2 FROM restaurant_info WHERE state = '$state1' AND city = ('$selected_cities') ORDER BY rest_id");
while ($got_city2 = mysql_fetch_array($Get_City2)) {
$rest_id = $got_city2['rest_id'];
$rest_name = $got_city2['rest_name'];
$city = $got_city2['city'];
$ad2 = $got_city2['ad_space2'];
if($ad2 == '1'){
$is_sold2 = "<font color='red'>sold</font>";
}else{
$is_sold2 = "<font color='green'>available</font><input name='ad2[$rest_id]' id='ad2' type='checkbox' value='1[$rest_id]'/>";
}
echo $rest_name." in ".$city." is ".$is_sold2."<br />";
}
echo "</td><td><h2>Spot 3</h2>";
$Get_City3 = mysql_query("SELECT rest_id, rest_name, city, ad_space3 FROM restaurant_info WHERE state = '$state1' AND city = ('$selected_cities') ORDER BY rest_id");
while ($got_city3 = mysql_fetch_array($Get_City3)) {
$rest_id = $got_city3['rest_id'];
$rest_name = $got_city3['rest_name'];
$city = $got_city3['city'];
$ad3 = $got_city3['ad_space2'];
if($ad3 == '1'){
$is_sold3 = "<font color='red'>sold</font>";
}else{
$is_sold3 = "<font color='green'>available</font><input name='ad3[$rest_id]' id='ad3' type='checkbox' value='$rest_id'/>";
}
echo $rest_name." in ".$city." is ".$is_sold3."<br />";
}
echo "</td>";
echo "<tr><td colspan='5'><center><input type='submit' name='submit' value='Submit'></center></td></tr></table></form>";
mysql_close();
?>
With this code when I view the source through firefox I can see that the names of my checkboxes are coinciding with the restaurant ids "<input name='ad1[37]'"(which is AWESOME!). My problem now is how do I use that to update my database?
My mark_sold.php page consists mainly of this:
mysql_query("UPDATE restaurant_info SET ad_space1='$ad1', ad_space2='$ad2' WHERE rest_id='$rest_id'") or die(mysql_error());
I imagine I need to do something array() related but I have no idea what.