Hi, this is again, following on from this question I posted yesterday - my other question from yesterday
Webbiedave helped me enormously with his answer on the question I posted yesterday and it now all works great, but I've decided to complicate matters by adding an 'Image Title' box that enables the back-end user to add a 'title' to an uploaded gallery image. I've got this to work and it adds the 'title' to the database with the relative image, but when it then comes to update the 'title' text, I can't seem to get it to save back to the database.
This is the code I've written to update the 'Image Title' into the database: (Very bad and doesn't work :( )
if (!empty($_POST['title_ids'])) {
foreach ($_POST['title_ids'] as $titleId) {
$gtsql=mysql_query("UPDATE isgallery SET galleryTitle = 'How do I grab the updated title?' WHERE id = ".mysql_real_escape_string($titleId));
mysql_query($gtsql);
}
}
This is the code that displays the images from a seperate database and also adds them:
$galleryQuery=mysql_query("select * from isgallery where assoc_object = '".$_POST['id']."'");
echo '<ul class="gallery">'. PHP_EOL;
while($galleryResult=mysql_fetch_array($galleryQuery)) {
echo '<li><img src="../../images/properties/gallery/'.$galleryResult['imagename'].'" width="120" height="120" class="image" /><br />
<label for="delGallery'.$galleryResult['id'].'"><input id="delGallery'.$galleryResult['id'].'" type="checkbox" name="gallery_ids[]" value="'.$galleryResult['id'].'" /> Delete this image?</label><br />
<input type="text" style="width:120px;" name="galleryTitle" value="'.$galleryResult['galleryTitle'].'"><br />
<label for="updateTitle'.$galleryResult['id'].'"><input id="updateTitle'.$galleryResult['id'].'" type="checkbox" name="title_ids[]" value="'.$galleryResult['id'].'" /> Update title?</label><br />
</li>
'. PHP_EOL;
}
echo '</ul><br /><br />' . PHP_EOL;
echo '<label for="galleryFile">Add Image (*.jpg / *.gif): </label><input type="file" name="galleryFile" value=""><br />
<label for="galleryTitle">Image Title/Description: </label><input type="text" name="galleryTitle" value="'.$_POST['galleryTitle'].'"><br />
'.($_POST['imagename'] ? '
' : NULL).'
Hope this makes sense. Any help greatly appreciated. S