Jump to content

Checking checkbox and getting ID


kevinak

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/122914-checking-checkbox-and-getting-id/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.