Jump to content

[SOLVED] Array deletion showing same mesage every time


vinpkl

Recommended Posts

hi all

 

i have multiple checkboxes which holds value of "order_id" in my form based on arrays.

 

The code i m using works fine and deletes the order based on selected checkbox.

 

When order gets deleted then it shows message "Order deleted".

 

But the problem i m facing is that if the order doesnt gets deleted then also it shows message "Order deleted".

 

Means everytime it shows same message "Order deleted successfully" whether order gets deleted or not.

 

if(isset($_REQUEST['submit']))
{
$selcheckbox=array();
$selcheckbox=$_REQUEST['item'];
$count=count($selcheckbox);
for($i=0;$i<$count-1;$i++)
{
$del_id = $selcheckbox[$i];

$qry2 = "delete FROM new_order WHERE order_id=$del_id and payment_status='PENDING'";
$result2 = mysql_query($qry2);
if(mysql_query($qry2))
{
$msg="order ( ".$del_id." ) Deleted Successfully";
}
else
{
$msg="Error Deleting order";
}
}
}

 

This is html


echo "<td valign=top>". "<input type='checkbox' name='item[]' id='item[]' value=". $row['order_id']. ">"."</td>";

 

vineet

Link to comment
Share on other sites

change

if(isset($_REQUEST['submit']))

to

if(isset($_POST['item']))

 

then the code will only execute if any checkboxes are checked.

 

also change the $_REQUEST's to $_POST....

 

hi joel24

 

thanks for the reply. works fine.

 

vineet

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.