kevinak Posted September 5, 2008 Share Posted September 5, 2008 Ok this code generates images and checkboxes in a table for my site while($row = mysql_fetch_row($resultpets)) { echo "<tr><td><input type=checkbox name=petID".$row[0]."><img src=http://whimpsters.net/pets.php/".$row[0]."></td>"; Now, I need to somehow to check if one of the checkboxes are checked and if they are, I need to be able to use their ID number which is the same as $row[0]. But also relize that that number would have to be grabbed before it moves to the next image. Is there anyway to get it from the checkbox name or value? I've been trying to created an array and use the foreach function, but it always fails. I'm at a loss. Anyone? Thanks for reading Quote Link to comment https://forums.phpfreaks.com/topic/122914-checking-checkbox-and-getting-id/ Share on other sites More sharing options...
Ken2k7 Posted September 5, 2008 Share Posted September 5, 2008 Uh I don't think I understand. Is there something in the database that tells if it is checked? If not, then it's going to be a pain to recognize if a checkbox is checked before you move to the next image. JavaScript is the only way at that point. Quote Link to comment https://forums.phpfreaks.com/topic/122914-checking-checkbox-and-getting-id/#findComment-634803 Share on other sites More sharing options...
.josh Posted September 5, 2008 Share Posted September 5, 2008 Expanding/rewording what Ken2k7 said, if you have a field in your db that signifies whether something is (supposed to be) checked or not, you can add a condition in your loop that displays your images/etc.. If you are wanting something to be dynamically (not) shown based on whether the user checks something right then and there, you're going to have to do some event handling with javascript. We could be a bit more specific if you were to be a bit more specific in what you're goal here is. Quote Link to comment https://forums.phpfreaks.com/topic/122914-checking-checkbox-and-getting-id/#findComment-634887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.