vinpkl Posted June 22, 2009 Share Posted June 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 22, 2009 Share Posted June 22, 2009 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.... Quote Link to comment Share on other sites More sharing options...
vinpkl Posted June 22, 2009 Author Share Posted June 22, 2009 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 Quote Link to comment 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.