Note that there are some explanatory texts on larger screens.

plurals
  1. POneed to delete selected rows through checkbox with a single Delete button
    primarykey
    data
    text
    <p>okay this is the updated main php page now, ive cleared my previous post to make this clean, FYI...what im posting here are just my test page which is he exact replica of my actual page..just have different php page name...</p> <pre><code> &lt;link href="jquery-ui-1.10.2.custom/css/dark-hive/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /&gt; &lt;script type="text/javascript" src="jquery-ui-1.10.2.custom/js/jquery-1.9.1.js" &gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.js" &gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.min.js" &gt;&lt;/script&gt; &lt;link rel="stylesheet" href="style.css" /&gt; &lt;script type="text/javascript" src="SMP1_deletefromDB.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $("#results").show(); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#RetrieveList").on('click',function() { var xid = $('#XiD').val(); var date = $('#Date').val(); $.post('resultgenerator_test.php',{xid:xid, date:date}, function(data){ $("#results").html(data); }); return false; }); }); //post to delete.php file. In delete.php you can get the id's in $_POST['id'] as multidimensional array. You can handle the delete operation based on that $(document).ready(function(){ $("#DeletefromDB").on('click',function() { //get all the checked values from checkboxes var ids = $('input[name=checkbox]:checked').map(function () { return this.value; }).get(); if (ids.length === 0) return false; //show some error message //post to delete.php file. In delete.php you can get the id's in $_POST['id'] as multidimensional array. You can handle the delete operation based on that $.post('deletedata.php',{id : ids}, function(data){ $("#results").html(data); //handle the message based on success or error }); return false; }); }); &lt;/script&gt; &lt;/head&gt; &lt;body class="oneColFixCtrHdr"&gt; &lt;div id="container" style="width:auto"&gt; &lt;div id="header" style="background-color:#7BD12E"&gt; &lt;h1 align="left" style="color:#FFF; font-family: Arial, Helvetica, sans-serif;"&gt;PIS Ticket Tracking System&lt;/h1&gt; &lt;!-- end #header --&gt;&lt;/div&gt; &lt;div id="mainContent"&gt; &lt;h1 style="font-size:9"&gt;&lt;/h1&gt; &lt;form id="form1" name="form1" method="post" action=""&gt; &lt;p&gt; &lt;label for="Back"&gt;&lt;/label&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="button" name="Back" id="Back" value="Back To Main" href="#" onclick="return backAway();" /&gt; &lt;/p&gt; &lt;/form&gt; &lt;form id="form2" name="form2" method="post" action=""&gt; &lt;table width="741" border="0" align="center"&gt; &lt;tr&gt; &lt;th colspan="9" align="center" style="font-size:12px" scope="col"&gt;Xid, Name:&lt;span&gt; &lt;select name="XiD" id="XiD"&gt; &lt;option value="AAA"&gt;AAA&lt;/option&gt; &lt;option value="BBB"&gt;BBB&lt;/option&gt; &lt;option value="CCC"&gt;CCC&lt;/option&gt; &lt;option value="DDD"&gt;DDD&lt;/option&gt; &lt;option value="EEE"&gt;EEE&lt;/option&gt; &lt;option value="FFF"&gt;FFF&lt;/option&gt; &lt;option value="" selected="selected"&gt;&lt;/option&gt; &lt;/select&gt; &lt;/span&gt;&lt;span style="font-size:12px"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;label for="date"&gt;Date:&lt;/label&gt; &lt;input type="text" name="Date" id="Date" /&gt; &lt;/span&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th colspan="9" scope="col"&gt;&amp;nbsp;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th colspan="9" scope="col"&gt; &lt;div align="center"&gt; &lt;input name="action" type="button" id="RetrieveList" value="Retrieve List" /&gt; &lt;input name="action" type="button" id="DeletefromDB" value="Delete from DB" /&gt; &lt;input name="Clear" type="reset" id="Clear" value="Clear" /&gt; &lt;/div&gt; &lt;label for="Clear"&gt;&lt;/label&gt; &lt;div align="center"&gt;&lt;/div&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;div id="results"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and here is my 2nd php page that echoes the data into table format: Please read my comments below as I need it to clarify...</p> <pre><code> jQuery(document).ready(function () { jQuery("input[name=checkall]").click(function () { jQuery('input[name=checkall]').prop('checked', this.checked); jQuery('input[name=checkbox]').prop('checked', this.checked); }); // if all checkbox are selected, check the selectall checkbox // and viceversa jQuery("input[name=checkbox]").click(function(){ if(jQuery("input[name=checkbox]").length == jQuery("input[name=checkbox]:checked").length) { jQuery("input[name=checkall]").prop("checked", true); } else { jQuery("input[name=checkall]").prop("checked", false); } }); }); &lt;/script&gt; &lt;?php require 'include/DB_Open.php'; $xid = $_POST['xid']; $date = $_POST['date']; $sql="SELECT ars_no, phone_number, category_1, category_2, status, create_date, resolved_date, trouble_type_priority, ban_type, employee_id_name FROM tbl_main WHERE employee_id_name = '" . $xid . "' AND resolved_date = '" . $date . "'"; $myData = mysql_query($sql); echo "&lt;table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'&gt; &lt;tr&gt; &lt;th align='center'&gt;&lt;input id=checkall name=checkall type=checkbox value='' /&gt;&lt;/th&gt; &lt;th align='center'&gt;Remedy Ticket No.&lt;/th&gt; &lt;th align='center'&gt;Phone/Incident No.&lt;/th&gt; &lt;th align='center'&gt;Category 2&lt;/th&gt; &lt;th align='center'&gt;Category 3&lt;/th&gt; &lt;th align='center'&gt;Status&lt;/th&gt; &lt;th align='center'&gt;Create Date&lt;/th&gt; &lt;th align='center'&gt;Severity&lt;/th&gt; &lt;th align='center'&gt;Ban Type&lt;/th&gt; &lt;th align='center'&gt;Resolved Date&lt;/th&gt; </code></pre> <p>//<strong>*I have added this header so that im fetching the employee_id_name as well but just hiding it so i can delete it from my 3rd php...i used the following but still showing a very small cell on the Xid column...*</strong></p> <pre><code>&lt;th align='center' style='display:none'&gt;XiD&lt;/th&gt; &lt;/tr&gt;"; while($info = mysql_fetch_array($myData)) { echo "&lt;form action='resultgenerator_test.php' method='post'&gt;"; echo"&lt;tr&gt;"; echo "&lt;td align='center'&gt;" . "&lt;input type=checkbox name=checkbox value=" . " &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['ars_no'] . "&lt;input type=hidden name=ars_no value=" . $info['ars_no'] . " &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['phone_number'] . "&lt;input type=hidden name=phone_number value=" . $info['phone_number'] . " size='11' maxlength='11' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['category_1'] . "&lt;input type=hidden name=category_1 value=" . $info['category_1'] . "' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['category_2'] . "&lt;input type=hidden name=category_2 value=" . $info['category_2'] . "' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['status'] . "&lt;input type=hidden name=status value=" . $info['status'] . "' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['create_date'] . "&lt;input type=hidden name=create_date value=" . $info['create_date'] . "' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['trouble_type_priority'] . "&lt;input type=hidden name=trouble_type_priority value=" . $info['trouble_type_priority'] . " size='1' maxlength='1' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $info['ban_type'] . "&lt;input type=hidden name=ban_type value=" . $info['ban_type'] . " size='1' maxlength='1' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . "&lt;input type=text name=resolved_date value=" . $info['resolved_date'] . " size='8' maxlength='8' /&gt; &lt;/td&gt;"; echo "&lt;td align='center'&gt;" . "&lt;input type=hidden name=employee_id_name value=" . $info['employee_id_name'] . "' /&gt; &lt;/td&gt;"; echo "&lt;/tr&gt;"; echo "&lt;/form&gt;"; } echo "&lt;/table&gt;"; include 'include/DB_Close.php'; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>now look at the 3rd php page that ive created as u suggested and explained...please correct if u see any errors on the code:</p> <p><strong>LATEST UPDATE delete php:</strong></p> <pre><code>&lt;?php require 'include/DB_Open.php'; $id = $_POST['id']; $idtodelete = "'" . implode("','",$id) . "'"; $query = "DELETE FROM tbl_main WHERE ars_no in (" . $idtodelete . ")"; $myData = mysql_query($query); include 'include/DB_Close.php'; ?&gt; </code></pre> <p>thanks for all the help...:)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload