hadi_n3065 Posted December 29, 2008 Share Posted December 29, 2008 Hi I print out rows from a database in a table like this echo '<form action="" method="POST">'; for($i=0;$i<$num;$i++) { echo '<tr>'; echo '<td style="width: 300px" class="style11"> <span lang="en" class="style13"><a href="HomeDetails.php">Description</a></span></td>'; $record=mysql_result($result,$i,'Price'); echo '<td style="width: 300px" class="style15"> <span lang="en" class="style13"><strong>'.$record.'</strong></span></td>'; $record=mysql_result($result,$i,'Space'); echo '<td style="width: 300px" class="style15"> <span lang="en" class="style13"><strong>'.$record.'</strong></span></td>'; $record=mysql_result($result,$i,'City'); echo '<td style="width: 400px" class="style15"> <span lang="en" class="style13"><strong>'.$record.'</strong></span></td>'; $record=mysql_result($result,$i,'State'); echo '<td style="width: 400px" class="style15"> <span lang="en" class="style13"><strong>'.$record.'</strong></span></td>'; $record=$i+1; echo '<td style="width: 100px" class="style15"> <span lang="en" class="style13"><strong>'.$record.'</strong></span></td>'; $record=mysql_result($result,$i,'ID'); echo '<td class="style15"style="width: 100px" class="style11"> <input type="checkbox" name=chckbx'.$record.'></td>'; echo '</tr>'; }//end of for echo '</table></div><input type="submit" name="BtnDel" value="Delete"></form>'; Now I want to submit this form to the next page and there I want to delete all rows where the checkbox have been checked. My problem is: How do I get the selected ones? Let's say that row1 and row 3 is checked. Then I would like to get the value 1 and 3 so I can remove the rows in the database with this id. On this page there will be a lot of other checkbox.(If that is possible?) Thanks , Hadi Link to comment https://forums.phpfreaks.com/topic/138770-help-get-the-name-of-checkboxes-that-is-checked-in-a-search/ Share on other sites More sharing options...
rhodesa Posted December 29, 2008 Share Posted December 29, 2008 change this: $record=mysql_result($result,$i,'ID'); echo '<td class="style15"style="width: 100px" class="style11"> <input type="checkbox" name=chckbx'.$record.'></td>'; to $record=mysql_result($result,$i,'ID'); echo '<td class="style15"style="width: 100px" class="style11"> <input type="checkbox" name="chckbx['.$record.']"></td>'; then in your processing code, loop over $_POST['chkbx']: foreach(array_keys($_POST['chkbx']) as $id){ echo "Item $id was checked<br>"; } edit: fixed my foreach Link to comment https://forums.phpfreaks.com/topic/138770-help-get-the-name-of-checkboxes-that-is-checked-in-a-search/#findComment-725580 Share on other sites More sharing options...
hadi_n3065 Posted December 30, 2008 Author Share Posted December 30, 2008 Hi, You Solved My Poblem, Thank You. bYe Link to comment https://forums.phpfreaks.com/topic/138770-help-get-the-name-of-checkboxes-that-is-checked-in-a-search/#findComment-726035 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.