I have two pages going on here. The first is an edit page, the second is the database execution of the edit string. The first page (edit.php) reads the database and fills in some checkboxes. I've got this to work properly, but when I have an element from the database read as unchecked and you check it, it passes it to the second page like it's still unchecked.
edit.php:
while ($photo_row=mysql_fetch_array($edit_photo_results))
{
$photo_id = $photo_row['photo_id'];
$photo_name = $photo_row['photo_name'];
$thumb_name = $photo_row['thumb_name'];
$photo_share_ind = $photo_row['photo_share_ind'];
if ($photo_share_ind == 1)
{
$photo_share_ind = "CHECKED";
}else{
$photo_share_ind = "";
}
$nbrow++;
if ($nbrow % 4 === 0){$break = "</tr><tr>\n";}else{$break = "";}
$photo_form.=<<<RPH
<td class='album_folder'><img src='thumbnails/$thumb_name' border=0>\n\t\t<br><input type='text' name='photo_name[$nbrow]' value='$photo_name'>
<br><input type='hidden' name='photo_id[$nbrow]' value='$photo_id'></td>
<td class='album_folder'><input type='checkbox' name='photo_share_ind[$nbrow]' value=$photo_share_ind $photo_share_ind></td>\n
$break
RPH;
}
Looks like this on the HTML page as it should:
<td class='album_folder'><input type='checkbox' name='photo_share_ind[1]' value= ></td>
edit_commit.php:
foreach ($_POST['photo_name'] as $key=>$value)
{
$photo_id = array_filter($_POST['photo_id']);
$photo_share_ind = array_filter($_POST['photo_share_ind']);
if ($photo_share_ind[$key] == "CHECKED"){$photo_share_ind_array = '1';}else{$photo_share_ind_array = '0';}
$photo_sql = "update photo set photo_name = '$value', photo_share_ind = '$photo_share_ind_array' where photo_id = '$photo_id[$key]'";
$photo_result = mysql_query ($photo_sql) or die ("Invalid Query: " . mysql_error());
echo "\n<!-".$photo_sql."->";
echo "<!-".$photo_share_ind[$key]."->";
unset($photo_share_ind);
}
Looks like this in HTML:
<!-update photo set photo_name = '01.jpg', photo_share_ind = '0' where photo_id = '11'-><!-->
What am I missing to make this pass to the second page with the updated information? It seems to work fine when going from a CHECKED to an UNCHECKED, but not vice versa. Thanks!
EDIT: Should have shared this too from the edit.php page:
<Form action='edit_commit.php?album_id=$_GET[album_id]' method='post'>