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

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.