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

Link to comment
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.