lordphate Posted March 9, 2009 Share Posted March 9, 2009 Hey Everyone I'm looking for some advice about how to go about doing a facebook-like photo captions, they use a single form [from what i can tell] and allow you to add captions to a maximum of 60 photos [i think this is just a set limit for them, never could upload more than 60 in a single album]. http://www.arshem.net/facebook-captions.jpg -- WARNING BIG IMAGE 800k How would you go about making the form for that ? Here's what i was THINKING, but not sure FORM CODE $form = ' <form name="photo_caption" action="index.php" method="post"> <input type="hidden" name="handler" value="gallery"> <input type="hidden" name="action" value="edit_caption"> foreach($photos as $photo) { $form .= '<textarea cols=40 rows=4 name="caption[]" id="'.$photo["pho_id"].'">'; } $form .= '<input type="submit" value="Edit Captions">'; echo $form; think that will work so far ? [$photos will be a variable set after the photos are uploaded] Here is the php [and yes i'm not double checking my code, i'll recheck when i'm actually coding it for my site]. foreach($_POST["caption"] as $caption) { mysql_query("UPDATE gallery SET caption='".$caption."',update='".time()."' WHERE pho_id='".$_POST["pho_id"]); }//foreach I have a feeling i can't do $_POST["pho_id"]..what could i use instead ? Thanks! Brandon Link to comment https://forums.phpfreaks.com/topic/148543-photo-caption-advice/ Share on other sites More sharing options...
JonnoTheDev Posted March 9, 2009 Share Posted March 9, 2009 Use the photos database id as the array key for the textarea name value <textarea cols=40 rows=4 name="caption[".$photo['pho_id']."]"> then to process foreach($_POST['caption'] as $photoId => $value) { mysql_query("UPDATE gallery SET caption='".mysql_real_escape_string($value)."',update='".time()."' WHERE pho_id='".$photoId."'"); } Link to comment https://forums.phpfreaks.com/topic/148543-photo-caption-advice/#findComment-780183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.