This is the result from a print_r($_POST) before my loop:
Array ( [piccap] => Array ( [0] => up [1] => down ) [photoid] => Array ( [0] => 25 [1] => 83 ) [catid3] => 2 [submit] => Edit )
So, what I am submitting is being posted but the database is only being updated with the second entry.
My loop is only returning the last item.
Editing the first three entries of a category with eight resulted in no change.
But updating the last picture caption worked.
I think it must be my loop. I tried a foreach with no joy but have a funny feeling i should probably be using a foreach within a foreach - a thing I’m clueless as to its implimentation.
This is what I have at the moment
print_r($_POST);
$id = $_POST['photoid'];
for ($i = 0; $i < count($id); $i++) {
$pid = $_POST['photoid'];
$newcaption = $_POST['piccap'];
$sql = "UPDATE gallery_photos SET
photo_caption='$newcaption[$i]'
WHERE photo_id='$pid[$i]'";
}
if (@mysql_query($sql)) {
echo '<h3 id="message">Update successful.</h3>';
} else {
echo '<h3 id="message">Error updating photo caption: ' .
mysql_error() . '</h3>';
}
Any help appreciated, thankyou.