powaz Posted May 13, 2007 Share Posted May 13, 2007 I have problem with array... Maybe somebody know how to send to ch.php arrary of checkbox's not only one value? ??? I'm doing like this but only one value i can be sended.... while ($row = mysql_fetch_array($query)){ echo '<form action="ck.php" method="post">'; echo '<tr><td><input type="checkbox" name="box[]" value="'.$row["cID"].'">'.$row["cID"].'</td>'; .... echo '<td>'.$row["price"].'</td>'; } echo '</tr><tr><td><input type="submit" value="DELETE"/></td><td><a href="new.htm">new</a></td></tr>'; echo '</form></table>'; } ck.php <? $id=$_POST['box'][0]; ?> Thanx for your answers Quote Link to comment https://forums.phpfreaks.com/topic/51177-php-checkbox/ Share on other sites More sharing options...
Barand Posted May 13, 2007 Share Posted May 13, 2007 ck.php <?php foreach ($_POST['box'] as $id) { echo $id, '<br>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51177-php-checkbox/#findComment-251969 Share on other sites More sharing options...
Barand Posted May 13, 2007 Share Posted May 13, 2007 PS if you want to delete the selected items, $delete_ids = join (',' , $_POST['box']); $sql = "DELETE FROM mytablename WHERE cID IN ($delete_ids)"; mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/51177-php-checkbox/#findComment-251974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.