okay, this is what I'm doing and I dont' have the exact code in front of me because I'm at work right now, but here is the jist of it.
When the user comes to this page, the first thing the see is a drop down box with a store location, they select the location for the photos they wish to edit or delete, this sets the variable $locID which is the name of the menu and sets a variable called form to "continue". This now goes to the portion of the same page that says if($form == "continue"){ yada, yada, yada..
Once it gets to this section, the database is queried to get all images and descriptions based on the $locID. The following is the code and what is generated:
echo"
<form action='$path/admin/editLocPhotos.php?locID=".$locID."' method='post' name='editPhotos' enctype='multipart/form-data'>
<input type='hidden' name='MAX_FILE_SIZE' value='307200' />
<table width='100%' border='0' cellspacing='0' cellpadding='3' summary='This table is for display only.'>";
$sql = "Select * From locPhotos Where locID = '".$locID."' Order By id ASC";
$query = mysql_query($sql);
$i = 0;
while($result = mysql_fetch_array($query)){
echo"<tr valign='top'>
<td><strong>Description ".($i + 1)."</strong></td>
<td><strong>Current Image</strong></td>
<td> </td>
</tr>
<tr valign='top'>
<input type='hidden' name='id[$i]' value='".$result['id']."' />
<td><textarea class='textBoxStyle' cols='40' rows='2' name='desc[$i]'>".$result['description']."</textarea></td>
<td><img src='../locationImages/".$result['pic']."' width='90' height='71' class='menuThumb' alt='location image' /></td>
<td><strong>Delete</strong> <input type='checkbox' name='delete[$i]' value='delete[$i]'></td>
</tr>";
$i++;
}
echo"
<tr>
<td> </td>
<td><input type='submit' name='upload' value='Submit' class='submitStyle' />
<input type='hidden' name='form' value='edit'>
<input type='hidden' name='num' value='$i'></td>
</tr>
</table>
</form>";
}
I am using $locID = $_GET['locID']; because I am grabbing it from the URL string. this is the only way I was able to get it otherwise that variable was lost if I didn't append it to the string and then grab it from there. Although, now that I think about it I could actually get rid of that variable at this point because it doesn't really need to be updated. I really just need it to get all images at first.
Anyway, I still don't really now where to go from here. Because I need to more or less do an "else" but I can't do that with a foreach loop. If the box is not checked or $delete_items as $id is not true for the next item in the list, I need it to be updated in the database in case they have changed anything.
Thanks again for your help.