Forum Moderators: coopster

Message Too Old, No Replies

Silly Multiple Checkboxes Problem

I am sure there is an easy answer, I just don't know what it is!

         

tennis fan28

12:16 am on Sep 2, 2007 (gmt 0)

10+ Year Member



Good evening,
While I am sure there is an easy solution to this problem, it escapes me at the moment. I am trying to batch add captions for pictures in my database and came up with a very simple form where I can check off the boxes and add in my caption for those pictures. My problem is, even though I have the same name for each checkbox, it only posts the name of the last one I check.

Here is my script:
<?php
$query = "SELECT * FROM pictures ORDER BY filename ASC";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
$pid = $r["pictureid"];
$filename = $r["filename"];
$caption = $r["caption"];
echo "<input type=\"checkbox\" name=\"picture\" value=\"$pid\"> $filename <input type=\"text\" name=\"caption\" length=\"45\" value=\"$caption\">\n<br>";
}
?>

On my action page, if I just echo the value for the checkboxes, $picture, it spits out the most recent one, not an array of all the boxes I've checked like I thought it would.

Any help you guys can give me, I would appreciate it!

cameraman

12:50 am on Sep 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make the name of the checkboxes
picture[]