さて、これは更新されたメインのphpページです。これをきれいにするために以前の投稿をクリアしました。参考までに...ここに投稿しているのは、私の実際のページの正確なレプリカである私のテストページです..異なるphpページ名を持っているだけです...
<link href="jquery-ui-1.10.2.custom/css/dark-hive/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-ui-1.10.2.custom/js/jquery-1.9.1.js" ></script>
<script type="text/javascript" src="jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.js" ></script>
<script type="text/javascript" src="jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.min.js" ></script>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="SMP1_deletefromDB.js"></script>
<script>
$(document).ready(function(){
$("#results").show();
});
</script>
<script type="text/javascript">
$(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;
});
});
</script>
</head>
<body class="oneColFixCtrHdr">
<div id="container" style="width:auto">
<div id="header" style="background-color:#7BD12E">
<h1 align="left" style="color:#FFF; font-family: Arial, Helvetica, sans-serif;">PIS Ticket Tracking System</h1>
<!-- end #header --></div>
<div id="mainContent">
<h1 style="font-size:9"></h1>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="Back"></label>
<input type="button" name="Back" id="Back" value="Back To Main" href="#" onclick="return backAway();" />
</p>
</form>
<form id="form2" name="form2" method="post" action="">
<table width="741" border="0" align="center">
<tr>
<th colspan="9" align="center" style="font-size:12px" scope="col">Xid, Name:<span>
<select name="XiD" id="XiD">
<option value="AAA">AAA</option>
<option value="BBB">BBB</option>
<option value="CCC">CCC</option>
<option value="DDD">DDD</option>
<option value="EEE">EEE</option>
<option value="FFF">FFF</option>
<option value="" selected="selected"></option>
</select>
</span><span style="font-size:12px">
<label for="date">Date:</label>
<input type="text" name="Date" id="Date" />
</span></th>
</tr>
<tr>
<th colspan="9" scope="col"> </th>
</tr>
<tr>
<th colspan="9" scope="col">
<div align="center">
<input name="action" type="button" id="RetrieveList" value="Retrieve List" />
<input name="action" type="button" id="DeletefromDB" value="Delete from DB" />
<input name="Clear" type="reset" id="Clear" value="Clear" />
</div>
<label for="Clear"></label>
<div align="center"></div></th>
</tr>
</table>
</form>
<div id="results">
</div>
</div>
データをテーブル形式にエコーする 2 番目の php ページを次に示します。
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);
}
});
});
</script>
<?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 "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'>
<tr>
<th align='center'><input id=checkall name=checkall type=checkbox value='' /></th>
<th align='center'>Remedy Ticket No.</th>
<th align='center'>Phone/Incident No.</th>
<th align='center'>Category 2</th>
<th align='center'>Category 3</th>
<th align='center'>Status</th>
<th align='center'>Create Date</th>
<th align='center'>Severity</th>
<th align='center'>Ban Type</th>
<th align='center'>Resolved Date</th>
// *このヘッダーを追加して、employee_id_name もフェッチしますが、それを非表示にして、3 番目の php から削除できるようにします...次を使用しましたが、Xid 列に非常に小さなセルを表示しています... *
<th align='center' style='display:none'>XiD</th>
</tr>";
while($info = mysql_fetch_array($myData))
{
echo "<form action='resultgenerator_test.php' method='post'>";
echo"<tr>";
echo "<td align='center'>" . "<input type=checkbox name=checkbox value=" . " </td>";
echo "<td align='center'>" . $info['ars_no'] . "<input type=hidden name=ars_no value=" . $info['ars_no'] . " </td>";
echo "<td align='center'>" . $info['phone_number'] . "<input type=hidden name=phone_number value=" . $info['phone_number'] . " size='11' maxlength='11' /> </td>";
echo "<td align='center'>" . $info['category_1'] . "<input type=hidden name=category_1 value=" . $info['category_1'] . "' /> </td>";
echo "<td align='center'>" . $info['category_2'] . "<input type=hidden name=category_2 value=" . $info['category_2'] . "' /> </td>";
echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . "' /> </td>";
echo "<td align='center'>" . $info['create_date'] . "<input type=hidden name=create_date value=" . $info['create_date'] . "' /> </td>";
echo "<td align='center'>" . $info['trouble_type_priority'] . "<input type=hidden name=trouble_type_priority value=" . $info['trouble_type_priority'] . " size='1' maxlength='1' /> </td>";
echo "<td align='center'>" . $info['ban_type'] . "<input type=hidden name=ban_type value=" . $info['ban_type'] . " size='1' maxlength='1' /> </td>";
echo "<td align='center'>" . "<input type=text name=resolved_date value=" . $info['resolved_date'] . " size='8' maxlength='8' /> </td>";
echo "<td align='center'>" . "<input type=hidden name=employee_id_name value=" . $info['employee_id_name'] . "' /> </td>";
echo "</tr>";
echo "</form>";
}
echo "</table>";
include 'include/DB_Close.php';
?>
</body>
</html>
あなたが提案し、説明したように作成した3番目のphpページを見てください...コードにエラーがある場合は修正してください:
最新の更新 PHP を削除:
<?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';
?>
すべての助けをありがとう... :)