Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.