Jump to content

Recommended Posts

Ok this is what I have. I am not getting an error at all. What happens is that when I select an item to delete and hit the delete button the page just refreshes and that's it. The item or items that were checked do not get deleted. I am getting a value for <?=$row['id']?> so that is not the problem. Something is happening where the page is loosing the post. Because when I do echo $del_id;  I get nothing. However, if I hardcore a number into the query like $del = $db->query("DELETE FROM `guide_order` WHERE id = '3'");  it works just fine.

 

<?php


while($row = $db->fetch_array())	{
	?>
		<form id='order_form1' action='?page=guide' method='post'>
		<input type='hidden' name='pre_id' value='<?=$row['id']?>'/>
				<tr>
				<td align='center'><input type='text' name='amount' size='5' value='<?=$row['amount']?>' /></td>
				<td align='center'><?=$row['name']?></td>
                    <td align='center'><input type='text' name='priority' size='5' value='<?=$row['priority']?>' /></td>
				<td align='center'><input name="checkbox[]" type="checkbox" value="<?=$row['id']?>"></td>
				</tr>
		</form>

	<?php
}
?><br />
</table>
<form id='order_form' action='?page=guide' method='post'>
<input type='hidden' name='user_id' value='<?=$user_id?>'/><br />
  Delivery Date:  <input type="text" name="deliver" size="20" /><br /><br />
  <input type='submit' name='submit' value='Submit Order'/>  <input name="delete" type="submit" value="Delete">
<?php
// Check if delete button active, start this
$delete = $_REQUEST['delete'];
if( $delete != '' ){
$checkbox = $_REQUEST['checkbox'];
$count = count($_REQUEST['checkbox']);
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$del = $db->query("DELETE FROM `guide_order` WHERE id = '$del_id'");

}

// if successful redirect
if($del){
echo "<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php?page=guide\"></html>";
}
}
?>
	</form>

 

Any help would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/131281-solved-php-delete-multiple-checkboxes/
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.