Hi all,
I hope someone can help me out here as I think I am close but am not sure where to go from here. The problem is:
I have a cms where a user can see a list of photos in the gallery.
I provide them the ability to select what photos they want to appear on a particular webpage.
The problem I have is that the user wants to be able to put the photos in whatever order they choose.
So, I have a form (see attached), the html code is:
<table width="566px" cellspacing="0" border="0"> <tr>
<td width="33%">
<div class="serviceCell">
<input type='checkbox' checked='checked' name='photos[][0]' value='119' /> Bathroom Sin...
<img src="./images/help.gif" title="Enter an integer to signify the order in which this image will appear on the webpage." alt="Enter an integer to signify the order in which this image will appear on the webpage."/> <input type="text" size="2" name="photos[][1]" value="0"/> </div>
</td>
<td width="33%">
<div class="serviceCell">
<input type='checkbox' checked='checked' name='photos[][0]' value='113' /> Courtyard 1
<img src="./images/help.gif" title="Enter an integer to signify the order in which this image will appear on the webpage." alt="Enter an integer to signify the order in which this image will appear on the webpage."/> <input type="text" size="2" name="photos[][1]" value="0"/> </div>
</td>
<td width="33%">
<div class="serviceCell">
<input type='checkbox' name='photos[][0]' value='114' /> Courtyard 2
<img src="./images/help.gif" title="Enter an integer to signify the order in which this image will appear on the webpage." alt="Enter an integer to signify the order in which this image will appear on the webpage."/> <input type="text" size="2" name="photos[][1]" value=""/> </div>
</td>
</tr>...
Now, lets assume that the user ticked the box next to 'Courtyard 2' and entered an integer '1' in the input box to signify that this image should be displayed 1st on the chosen webpage. These 2 values go into the multidimensional array (photoid, ranking) and are submitted in the form to php in the photos[][] array.
But here is where I have the problem. I am trying to extract the values from the array and then do an insert to a table in mysql. My syntax must be wrong somewhere so I am asking anyone to please offer any advice:
if (isset($_REQUEST['submitted'])){
$photos = $_REQUEST['photos'];
...
if(!empty($photos)){
foreach($photos as $photoID){
$sql = "INSERT IGNORE INTO menuItemPhotos
SET photoid='$photoID[0]', menuItemid='$id', ranking='$photoID[1]'";
$ok = @mysql_query($sql); // execute the query
} // End of foreach($photos as $photoID){
} // End of if(!empty($photos)){
Thanks
Conor
[attachment deleted by admin]