0

I have a form with 640 cards each with a checkbox so the user can mark the ones he owns.

I'm wondering how to write the update SQL statement to take each of the 640 card ids and insert/update into the db.

Each row is created by this code:

echo "<td>"?>
         <form name="some form" action="editform.php" method="post">
         <input type="checkbox" name="<?php 
echo $row['stickerID'] ?>" value=" <?php echo $row['stickerStatus'] ?> ">
         <?php "</td>";
echo "</tr>"; 
}

I know I need some kind of for each loop in php. But how do I get the 640 individual checkboxes from the post?

1
  • Var_dump the $_post and look at the checkbox values. From there do a foreach post ... Commented Apr 9, 2014 at 3:36

1 Answer 1

2

suggest you name them like so

<input type="checkbox" name="stickerid[<?php 
echo $row['stickerID'] ?>]" value=" <?php echo $row['stickerStatus'] ?> ">

then you can loop through the $_POST['stickerid'] array

foreach($_POST['stickerid'] as $k=>$v ){
//code
//$k=id
//$v=status
}
Sign up to request clarification or add additional context in comments.

1 Comment

beat me to the punch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.