Jump to content

Checking checkboxes in a generated table


kevinak

Recommended Posts

Hello.

I have a query that checks for pet IDs based off a user's id.

It generates a table with all the ones that it finds with this code

 

//checks if any results are returned
if (mysql_num_rows($resultpets) > 0) {
//sets up my table
echo"<table border=1 width=500>";
//For each pet id found, it will add a column
while($row = mysql_fetch_row($resultpets)) {        

echo "<tr><td><center><img src=http://whimpsters.net/pets.php/".$row[0]." style='border-style: none'><input type=checkbox name=".$petname[$row]." value=".$row[0]."  /></td>";

//4 more columns to make 5 column rows

 

The key point to this being...

 

<input type=checkbox name=".$petname[$row]." value=".$row[0]."  />

 

Now I have the checkbox's name to equal the array $petname[petid] and the value is just the pet id number.

 

Now, using a for each loop, how can I check which check boxes have been marked?

 

Would it be anything like this

 

foreach($petname as $key => $value) {
if(isset($key)) {
//do stuff for checked boxes
}
}

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.