glow Posted November 13, 2013 Share Posted November 13, 2013 (edited) Hi can someone tell me by looking at this php file why the delete function attached to the delete button is not working? <?php //session_start(); require('../includes/db-connection.php'); include('../modules/general_functions.php'); include('../modules/db_functions.php'); ini_set('session.cache_limiter',''); if (!session_is_registered('admin_login')) { header('location:login.php'); } if(isset($_REQUEST['beg'])){ $beg = $_REQUEST['beg']; }else{ $beg = 0; } $Sno = $beg + 1; $tablename = "orders"; $tablename2 = "order_items"; $_tablename = "orders"; if(count($_POST)){ $_orderby = sql_replace(trim($_POST['orderby'])); $_isDel = $_POST['delete']; $_isApprove = $_POST['approve']; $_isDisApprove = $_POST['disapprove']; //$_tablename = "mcblogs";// Retrieving Classified Table Name //If Delete button is pressed. if($_isDel){ $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++) { $_tids .= $_ids[$i] . ","; } $_tids = substr($_tids, 0, -1); if($_tids) { $sql = "DELETE FROM $tablename2 where order_id in ($_tids)"; mysql_query($sql); $sql = "DELETE FROM $_tablename where order_id in ($_tids)"; if(mysql_query($sql)) { $_SESSION['flag'] = 'Delete'; //$error = "Content(s) approved successfully. "; } $_tids = ""; } } else{ $error = "Please check some Content(s) to approve"; } } //If Approve button is pressed. if($_isApprove){ $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++){ $_tids .= $_ids[$i] . ","; } $_tids = substr($_tids, 0, -1); if($_tids){ $sql = "Update $_tablename set status='Delivered' where order_id in ($_tids)"; if(mysql_query($sql)){ $error = "Content(s) approved successfully. "; } $_tids = ""; } } else{ $error = "Please check some Content(s) to approve"; } } //If Disapprove button is pressed. if($_isDisApprove){ $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++){ $_tids .= $_ids[$i] . ","; } $_tids = substr($_tids, 0, -1); if($_tids){ $sql = "Update $_tablename set status='Pending' where order_id in ($_tids)"; if(mysql_query($sql)){ $error = "Content(s) disapproved successfully. "; } $_tids = ""; } } else{ $error = "Please check some Content(s) to disapprove"; } } } if(isset($_POST['act'])){ if($_POST['act'] == 'Del') { $condition=array("clid" => $_POST['id']); $rs= select_table($tablename,$condition); if ($rs[0]) { $_SESSION["flag"] = 'Not_Deleted'; } else{ $condition=array("oid" => $_POST['id']); delete_table($tablename,$condition); } } } /*$total_query = "select * from orders, order_items where orders.order_id = order_items.order_id GROUP By orders.order_id";*/ /*$total_query = "SELECT COUNT(distinct a.order_id) as tot_rec FROM ".$tablename." as a,".$tablename2." as b WHERE a.order_id=b.order_id GROUP By a.order_id";*/ $total_query = "SELECT COUNT(distinct order_id) as tot_rec FROM `order` WHERE status ='Completed'"; $total_result = mysql_query($total_query); $total_res = mysql_fetch_array($total_result); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>..:: Mahatma Gandhi - Admin Panel ::..</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> <script language="JavaScript"> function find_crewtype() { document.frm.searchr.value=''; document.frm.searcht.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function find_users(st) { document.frm.searchr.value=st; document.frm.searcht.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function find_usersa() { document.frm.searchr.value=''; document.frm.searcht.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function find_userst() { document.frm.searchr.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function view_record(id) { document.frm.id.value=id; document.frm.action = "detail_orders.php?oid="+id; document.frm.submit(); } function add_record(id) { document.frm.action = "add_orders.php"; document.frm.submit(); } var records_per_page = 30; function prev(beg1) { document.frm.beg.value = (beg1*1)-records_per_page; document.frm.submit(); } /////////////////////////////////////////////////////////////////////////////////////////// function next(beg1) { document.frm.beg.value = (beg1*1)+records_per_page; document.frm.submit(); } /////////////////////////////////////////////////////////////////////////////////////////// function gotopage() { var abc = document.frm.jumppage.selectedIndex; var val = document.frm.jumppage[abc*1].value; document.frm.beg.value = ((val*1)*records_per_page)-records_per_page; document.frm.submit(); } /////////////////////////////////////////////////////////////////////////////// function delete_record(id, beg) { var buttonOk; buttonOk = confirm("Are you sure you want to delete this record ?"); if(buttonOk) { document.frm.id.value=id; document.frm.act.value="Del"; document.frm.action = "orders.php"; document.frm.submit(); } } ////////////////////////////////////////// function CheckAll(){ for (var c=0; c<document.frm.elements.length; c++){ var e = document.frm.elements[c]; if (e.name != 'selectUnselecrAll') e.checked = document.frm.selectUnselecrAll.checked; } } </script> </head> <body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0"> <table width="90%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="10" colspan="3"><?php include('header.php'); ?></td> </tr> <tr> <td width="28%" valign="top" class="bgcontents"><?php include('left.php'); ?></td> <td width="2%"></td> <td width="70%" class="bgcontents" valign="top"> <form name="frm" method="post" enctype="multipart/form-data"> <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="100%" height="25" class="page_heading">Orders Management</td> </tr> <tr> <td height="10"></td> </tr> <?php if($_SESSION['flag'] == 'Delete') { ?> <tr> <td class="text-red">Record deleted successfully</td> </tr> <?php } else if($_SESSION['flag'] == 'Update') { ?> <tr> <td class="text-red">Record Updated successfully</td> </tr> <?php } else if ($_SESSION['flag']=='Add') { ?> <tr> <td class="text-red">Record Added successfully</td> </tr> <?php } $_SESSION['flag']=''; ?> <tr><td height="10px"></td></tr> <tr><td> </td></tr> <tr class="row_bg" height="25px"> <td align="left" height="15" valign="top" class="sub_heading"> <input type="checkbox" name="selectUnselecrAll" onClick="CheckAll();">Select All to <input type="submit" name="approve" value=" Approve " class="button-nml" onclick="return confirm('Are you sure you want to Approve!');"> <input type="submit" name="disapprove" value=" Disapprove " class="button-nml" onclick="return confirm('Are you sure you want to Disapprove!');"> <input type="submit" name="delete" value=" Delete " class="button-nml" onclick="return confirm('Are you sure you want to Delete!');"> </td> </tr> <tr> <td> <table width="100%"> <tr><td width="50%"> </td> <td width="50%" align="right" class="sub_heading"><b>Total Records :<?php echo $total_res['tot_rec']; ?></b></td></tr></table> </td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="sub_heading"> <tr class="theading_bg"> <td width="6%">S.No</td> <td width="7%">Select</td> <td width="18%" height="30px">Client Name</td> <!--<td width="14%" height="30px">Contact No </td> <td width="22%">E-mail</td>--> <td width="21%">Order Date</td> <td width="19%">Delivery Time</td> <td width="9%" align="center">Price</td> <td width="10%" align="center">Status</td> <td width="10%" align="center">Details</td> </tr> <?php $records_per_page = 30; /* $cat_query="SELECT sum(b.oprice*b.oqty) as rs, sum(b.oqty) as p,a.*,b.* FROM ".$tablename." as a,".$tablename2." as b WHERE a.oid=b.oid"; $cat_query .= " GROUP By a.oid ";*/ /*$cat_query = "select * from orders, order_items where orders.order_id = order_items.order_id and orders.payment_status = 1 GROUP By orders.order_id";*/ $cat_query = "select * from `order`, order_product where `order`.order_id = order_product.order_id and `order`.status = 'Completed' GROUP By `order`.order_id"; // print_r ($cat_query); //exit; $res_query= mysql_query($cat_query); $total_rec= mysql_num_rows($res_query); if(isset($_REQUEST['beg'])){ $beg = $_REQUEST['beg']; }else{ $beg = 0; } $end = 0; if($total_rec >= 1) { $total_pages = ceil($total_rec/$records_per_page); $current_page = floor($beg/$records_per_page) +1; if($beg < $total_rec) { if($beg + $records_per_page < $total_rec) $end = $beg + $records_per_page; else $end = $total_rec; } $cat_query .= " ORDER BY `order`.order_id DESC LIMIT $beg,$records_per_page"; } $cat_result = mysql_query($cat_query); if(mysql_num_rows($cat_result) > 0) { while($cat_res = mysql_fetch_array($cat_result)) { $clientID = $cat_res['customer_id']; $QryClient = mysql_query("select * from client where id = '".$clientID."'"); $RslClient = mysql_fetch_array($QryClient); ?> <tr> <td height="30"><strong><?php echo $Sno; ?>.</strong></td> <td><input type="checkbox" name="ids[]" value ="<?php echo $cat_res["order_id"]; ?>"></td> <?php /*?><a href="mailto:<?php echo $cat_res['email']; ?>" class="left-nav"><?php echo $cat_res['email']; ?></a><?php */?> <td><?php echo $RslClient['fname']." ".$RslClient['lname']; ?></td> <?php /*?><td><?php echo $RslClient['phone']; ?></td><?php */?> <?php /*?><td><?php echo $RslClient['email']; ?></td><?php */?> <td><?php echo $cat_res['order_date']; ?></td> <td><?php echo $cat_res['delivery_time']; ?></td> <td align="center"><?php echo $currency_symbol["currencySymbol"]." ".$cat_res['total_price']; ?></td> <td align="center"><?php if ($cat_res['status'] == 'Completed') echo "Paid"; else echo "Not Paid"; ?> </td> <td align="center"><table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"><a href="javascript:view_record('<?php echo $cat_res['order_id']; ?>')" onClick="javascript:view_record('<?php echo $cat_res['order_id']; ?>')"><img src="../images/view-detail.png" width="30" height="30" title="View Details" border="0"></a></td> </tr> </table></td> </tr> <tr> <td height="1" colspan="10" bgcolor="#225544"></td> </tr> <?php $Sno++; } } else { echo '<tr><td colspan="7" height="30">No records.</td></tr>'; } ?> <tr> <td colspan="10"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="60%"><input name="sno" type="hidden" id="sno" value="<?php echo $Sno; ?>"> <input type="hidden" name="beg" value="<?php echo $beg; ?>"></td> <td width="40%"> </td> </tr> <tr> <td></td> <td align="right" class="sub_heading"><b>Total Records :<?php echo $total_res['tot_rec']; ?></b></td> </tr> </table></td> </tr> <tr> <td colspan="10"> </td> </tr> <tr> <td colspan="10"> <?php if($total_res['tot_rec'] > $records_per_page) { ?> <table width="37%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr class="bodyTextBold"> <td width="32%" align="center"><?php if($beg > 0) echo "<a href=\"javascript:prev('$beg')\" class=\"left-nav\"> <<Back </a></td>"; ?> <td width="29%" class="body-text"><div align="right">Page <SELECT name="jumppage" class="button-nml" onChange="gotopage()"> <?php for($x=1; $x <= $total_pages; $x++) { if($x==$current_page) { echo "<OPTION value=\"$x\" selected>$x</OPTION>"; } else { echo "<OPTION value=\"$x\">$x</OPTION>"; } } ?> </SELECT> </div></td> <td width="22%" class="sub_heading"> of <?php echo $total_pages; ?> </td> <td width="17%"><?php if($end < $total_rec) echo "<a href=\"javascript:next($beg)\" class=\"left-nav\">Next>></a>"; ?> </td> </tr> </table> <?php }?> </td> </tr> <tr> <td colspan="10"> </td> </tr> </table></td> </tr> </table></td> </tr> </table> <input name="id" type="hidden"> <input name="act" type="hidden" value=""> </form></td> </tr> <tr> <td height="10" colspan="3"><?php include('bottom.php'); ?></td> </tr> </table> </body> </html> in comparison to this other php page where the same delete function is working <?php error_reporting(0); session_start(); ini_set('session.cache_limiter',''); if (!session_is_registered('admin_login')) { header('location:login.php'); } require('../includes/db-connection.php'); include('../modules/general_functions.php'); include('../modules/db_functions.php'); $Sno = $beg + 1; $tablename = "products"; $tablenamec = "cataloge"; $_tablename = "products"; if(count($_POST)){ $_orderby = sql_replace(trim($_POST['orderby'])); $_isDel = $_POST['delete']; $_isApprove = $_POST['approve']; $_isDisApprove = $_POST['disapprove']; //$_tablename = "mcblogs";// Retrieving Classified Table Name //If Delete button is pressed. if($_isDel){ $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++){ $_tids .= $_ids[$i] . ","; } $_tids = substr($_tids, 0, -1); if($_tids){ $sql = "DELETE FROM $_tablename where id in ($_tids)"; if(mysql_query($sql)){ $_SESSION['flag'] = 'Delete'; //$error = "Content(s) approved successfully. "; } $_tids = ""; } } else{ $error = "Please check some Content(s) to approve"; } } //If Approve button is pressed. if($_isApprove){ $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++){ $_tids .= $_ids[$i] . ","; } $_tids = substr($_tids, 0, -1); if($_tids){ $sql = "Update $_tablename set status='1' where id in ($_tids)"; if(mysql_query($sql)){ $error = "Content(s) approved successfully. "; } $_tids = ""; } } else{ $error = "Please check some Content(s) to approve"; } } //If Disapprove button is pressed. if($_isDisApprove){ $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++){ $_tids .= $_ids[$i] . ","; } $_tids = substr($_tids, 0, -1); if($_tids){ $sql = "Update $_tablename set status='0' where id in ($_tids)"; if(mysql_query($sql)){ $error = "Content(s) disapproved successfully. "; } $_tids = ""; } } else{ $error = "Please check some Content(s) to disapprove"; } } } if($_POST['act'] == 'Del') { $condition=array("id" => $_POST['id']); $rs= select_table($tablename,$condition); if ($rs[0]) { $_SESSION["flag"] = 'Not_Deleted'; } else{ $condition=array("id" => $_POST['id']); delete_table($tablename,$condition); } } if ($_POST['searcht']) $total_query = "SELECT COUNT(*) as tot_rec FROM ".$tablename." as a,".$tablenamec." as b WHERE a.parentid=b.id AND a.heading LIKE '%".$_POST['searcht']."%'"; else if ($_POST['searchr']) $total_query = "SELECT COUNT(*) as tot_rec FROM ".$tablename." as a,".$tablenamec." as b WHERE a.parentid=b.id AND a.heading LIKE '".$_POST['searchr']."%'"; else $total_query = "SELECT COUNT(*) as tot_rec FROM ".$tablename." as a,".$tablenamec." as b WHERE a.parentid=b.id"; $total_result = mysql_query($total_query); $total_res = mysql_fetch_array($total_result); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>..:: Mahatma Gandhi - Admin Panel ::..</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> <script language="JavaScript"> function find_crewtype() { document.frm.searchr.value=''; document.frm.searcht.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function find_users(st) { document.frm.searchr.value=st; document.frm.searcht.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function find_usersa() { document.frm.searchr.value=''; document.frm.searcht.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function find_userst() { document.frm.searchr.value=''; document.frm.act.value=""; document.frm.beg.value=0; document.frm.submit(); } function update_record(id) { document.frm.id.value=id; document.frm.action = "update_products.php"; document.frm.submit(); } function add_record(id) { document.frm.action = "add_products.php"; document.frm.submit(); } var records_per_page = 30; function prev(beg1) { document.frm.beg.value = (beg1*1)-records_per_page; document.frm.submit(); } /////////////////////////////////////////////////////////////////////////////////////////// function next(beg1) { document.frm.beg.value = (beg1*1)+records_per_page; document.frm.submit(); } /////////////////////////////////////////////////////////////////////////////////////////// function gotopage() { var abc = document.frm.jumppage.selectedIndex; var val = document.frm.jumppage[abc*1].value; document.frm.beg.value = ((val*1)*records_per_page)-records_per_page; document.frm.submit(); } /////////////////////////////////////////////////////////////////////////////// function delete_record(id, beg) { var buttonOk; buttonOk = confirm("Are you sure you want to delete this record ?"); if(buttonOk) { document.frm.id.value=id; document.frm.act.value="Del"; document.frm.action = "products.php"; document.frm.submit(); } } ////////////////////////////////////////// function CheckAll(){ for (var c=0; c<document.frm.elements.length; c++){ var e = document.frm.elements[c]; if (e.name != 'selectUnselecrAll') e.checked = document.frm.selectUnselecrAll.checked; } } </script> </head> <body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0"> <table width="90%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="10" colspan="3"><?php include('header.php'); ?></td> </tr> <tr> <td width="28%" valign="top" class="bgcontents"><?php include('left.php'); ?></td> <td width="2%"></td> <td width="70%" class="bgcontents" valign="top"> <form name="frm" method="post" enctype="multipart/form-data"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="100%" height="25" class="page_heading">Products Management</td> </tr> <tr> <td height="10"></td> </tr> <?php if($_SESSION['flag'] == 'Delete') { ?> <tr> <td class="text-red">Product deleted successfully</td> </tr> <?php } else if($_SESSION['flag'] == 'Update') { ?> <tr> <td class="text-red">Product Updated successfully</td> </tr> <?php } else if ($_SESSION['flag']=='Add') { ?> <tr> <td class="text-red">Product Added successfully</td> </tr> <?php } $_SESSION['flag']=''; ?> <tr><td height="10px"></td></tr> <tr><td height="10px"></td></tr> <tr class="row_bg" height="25px"><td align="center"><input name="btn" type="button" class="button-nml" value="Add New Record" onClick="javascript:add_record(<?php echo $_REQUEST['uid']; ?>);"> <input type="text" name="searcht" class="input-nml" value="<?php echo $_REQUEST['searcht']; ?>"><input type="button" class="button-nml" value="Go" onClick="find_userst()"> <input type="button" class="button-nml" value="Show all" onClick="find_usersa()"> </td></tr> <tr><td> </td></tr> <tr><td align="center"> <?php // get_alphabetical();?> <input name="searchr" type="hidden" value="<?php echo $_REQUEST['searchr']?>"> <input name="orderr" type="hidden" value="<?php echo $_REQUEST['orderr']?>"> </td></tr> <tr><td> </td></tr> <tr class="row_bg" height="25px"> <td align="left" height="15" valign="top" class="sub_heading"> <table width="100%"><tr><td width="60%" align="left" class="sub_heading"> <input type="checkbox" name="selectUnselecrAll" onClick="CheckAll();">Select All to <input type="submit" name="approve" value=" Approve " class="button-nml" onclick="return confirm('Are you sure you want to Approve!');"> <input type="submit" name="disapprove" value=" Disapprove " class="button-nml" onclick="return confirm('Are you sure you want to Disapprove!');"> <input type="submit" name="delete" value=" Delete " class="button-nml" onclick="return confirm('Are you sure you want to Delete!');"> </td><td width="40%" align="right" class="sub_heading"></td> </tr> </table> </td> </tr> <tr> <td> <table width="100%"> <tr><td width="50%"> </td> <td width="50%" align="right" class="sub_heading"><b>Total Records :<?php echo $total_res['tot_rec']; ?></b></td></tr></table> </td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="sub_heading"> <tr class="theading_bg"> <td width="6%">S.No</td> <td width="7%">Select</td> <td width="18%" height="30">Product Image </td> <td width="32%" height="30">(Category) Product name </td> <td width="12%" align="center">Price</td> <td width="12%">Status</td> <td width="13%" align="center">Action</td> </tr> <?php $records_per_page = 30; if ($_POST['searcht']) $cat_query = "SELECT a.id,b.heading,a.heading,a.status,a.price,a.medium_price,a.extra_large,a.large_price,a.image,a.product_id FROM ".$tablename." as a,".$tablenamec." as b WHERE a.parentid=b.id AND a.heading LIKE '%".$_POST['searcht']."%'"; else if ($_POST['searchr']) $cat_query = "SELECT a.id,b.heading,a.heading,a.status,a.price,a.medium_price,a.large_price,a.extra_large,a.image,a.product_id FROM ".$tablename." as a,".$tablenamec." as b WHERE a.parentid=b.id AND a.heading LIKE '".$_POST['searchr']."%'"; else $cat_query="SELECT a.id,b.heading,a.heading,a.status,a.price,a.medium_price,a.large_price,a.extra_large,a.image,a.product_id FROM ".$tablename." as a,".$tablenamec." as b WHERE a.parentid=b.id"; $res_query= mysql_query($cat_query); $total_rec= mysql_num_rows($res_query); $beg = $_REQUEST['beg']; if($beg == '') $beg = 0; $end = 0; if($total_rec >= 1) { $total_pages = ceil($total_rec/$records_per_page); $current_page = floor($beg/$records_per_page) +1; if($beg < $total_rec) { if($beg + $records_per_page < $total_rec) $end = $beg + $records_per_page; else $end = $total_rec; } $cat_query .= " ORDER BY a.id ASC LIMIT $beg,$records_per_page"; } $cat_result = mysql_query($cat_query); if(mysql_num_rows($cat_result) > 0) { $Sno=1; while($cat_res = mysql_fetch_array($cat_result)) { ?> <tr> <td height="85"><strong><?php echo $Sno; // addslashes($cat_res['product_id']); ?>.</strong></td> <td><input type="checkbox" name="ids[]" value ="<?php echo $cat_res[0]; ?>"></td> <td> <?php if($cat_res['image']!='') { ?> <img src="../products/thumb/<?php echo $cat_res['image']; ?>" border="0"> <?php } ?> </td> <td>(<?php echo $cat_res[1]; ?>) <br /><?php echo $cat_res[2]; ?></td> <td align="center"><?php echo $currency_symbol['currencySymbol'].$cat_res["price"]." (S)"; ?><br/><?php echo $currency_symbol['currencySymbol'].$cat_res["medium_price"]." (M)"; ?><br/><?php echo $currency_symbol['currencySymbol'].$cat_res["large_price"]." (L)"; ?><br/><?php echo $currency_symbol['currencySymbol'].$cat_res["extra_large"]." (L+)"; ?></td> <td><?php if ($cat_res['status']) echo "Active"; else echo "In-Active"; ?> </td> <td align="center"><table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr> <!-- onClick="javascript:update_record('<?php //$cat_res['id']?>')"--> <td align="center"><a href="javascript:update_record('<?php echo $cat_res['id']?>')" ><img src="../images/edit.png" width="30" height="30" border="0"></a></td> <!-- <a href="update_products.php?prod_id=<?php //echo $cat_res['id']; ?>"><img src="../_layout/images/edit.png" width="30" height="30" border="0"></a> --> </tr> </table></td> </tr> <tr> <td height="1" colspan="9" bgcolor="#225544"></td> </tr> <?php $Sno++; } } else { echo '<tr><td colspan="9" height="30" align="center"><font color="#FF0000">No records Found.</font></td></tr>'; } ?> <tr> <td colspan="9"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="60%"><input name="sno" type="hidden" id="sno" value="<?php echo $Sno; ?>"> <input type="hidden" name="beg" value="<?php echo $beg; ?>"></td> <td width="40%"> </td> </tr> <tr> <td></td> <td align="right" class="sub_heading"><b>Total Records :<?php echo $total_res['tot_rec']; ?></b></td> </tr> </table></td> </tr> <tr> <td colspan="9"> </td> </tr> <tr> <td colspan="9"> <?php if($total_res['tot_rec'] > $records_per_page) { ?> <table width="37%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr class="bodyTextBold"> <td width="32%" align="center"><?php if($beg > 0) echo "<a href=\"javascript:prev('$beg')\" class=\"left-nav\"> <<Back </a></td>"; ?> <td width="29%" class="body-text"> <div align="right"> <SELECT name="jumppage" class="button-nml" onChange="gotopage()"> <?php for($x=1; $x <= $total_pages; $x++) { if($x==$current_page) { echo "<OPTION value=\"$x\" selected>$x</OPTION>"; } else { echo "<OPTION value=\"$x\">$x</OPTION>"; } } ?> </SELECT> </div> </td> <td width="22%" class="sub_heading"> of <?php echo $total_pages; ?> </td> <td width="17%"><?php if($end < $total_rec) echo "<a href=\"javascript:next($beg)\" class=\"left-nav\">Next>></a>"; ?> </td> </tr> </table> <?php }?> </td> </tr> <tr> <td colspan="9"> </td> </tr> </table></td> </tr> </table></td> </tr> </table> <input name="id" type="hidden"> <input name="act" type="hidden"> </form></td> </tr> <tr> <td height="10" colspan="3"><?php include('bottom.php'); ?></td> </tr> </table> </body> </html> the firts php code sample with non working delete function comes from Order.php and the second php sample with working delete function comes from products.php. Both come from the same shop script any help would be appreciated. Edited November 13, 2013 by glow Quote Link to comment Share on other sites More sharing options...
Barand Posted November 13, 2013 Share Posted November 13, 2013 Are the ids numeric in all cases? Quote Link to comment Share on other sites More sharing options...
glow Posted November 13, 2013 Author Share Posted November 13, 2013 Hi Guru, yes they are all numeric. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 13, 2013 Share Posted November 13, 2013 Check to see what mysql_error() contains after mysql_query(). Also echo $sql to see the query that is being executed Quote Link to comment Share on other sites More sharing options...
glow Posted November 13, 2013 Author Share Posted November 13, 2013 lol ...I'm afraid you lost me there I'm just starting with php. Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 13, 2013 Share Posted November 13, 2013 Well, you definitely need to slow down. I see some things in that code that are making things more difficult than they should be. For example this: $_ids = $_POST['ids']; $total = count($_ids); if($total){ for($i=0; $i<$total; $i++){ $_tids .= $_ids[$i] . ","; } Should be replaced with this //Set $_ids to all numeric, non-empty values in the POST array $_ids = array_filter(array_map('intval', $_POST['ids'])); //Check if there were any values if(count($_ids)){ //Create comma separated string of the values $_tids = implode(',', $_POST['ids']); 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.