php 选择某条查询出来的结果,进行修改,删除.
代码:
<?phpsession_start();if (empty($_SESSION['username'])) { echo "您还没有登录,不能访问当前页面!"; exit;}
?><body bgcolor="silver">
<form method= "POST" name="form1" action= "deletetask.php">
<?
require ("../include/conn.php");echo "<p><table border='1' cellspacing='1'><tr><th>选择</th><th>序号</th><th>任务描述</th><th>任务接收者</th><th>任务派发者</th><th>进度</th><th>开始日期</th><th>结束日期</th><th>等级</th><th>Display Detail</th></tr>";$sql="select * from task where (recipient='".$_SESSION['username']."' or distributer='".$_SESSION['username']."') and status<>1 order by grade desc,no desc";
$result=mysql_query($sql);while ($row=mysql_fetch_array($result)){
if ($row['grade']=='1')
$grade=str_replace('1','一般',$row['grade']);
else
$grade=str_replace('2','紧急',$row['grade']);
?>
<tr>
<td align = "center"> <input type="radio" name="id[]" value=<? echo ($row['id']); ?>></td>
<td align = "center"> <? echo ($row['no']); ?> </td>
<td align = "center"> <? echo ($row['describing']); ?> </td>
<td align = "center"> <? echo ($row['recipient']); ?> </td>
<td align = "center"> <? echo ($row['distributer']); ?> </td>
<td align = "center"> <? echo ($row['schedule']); ?> </td>
<td align = "center"> <? echo ($row['begindate']); ?> </td>
<td align = "center"> <? echo ($row['finishdate']); ?> </td>
<td align = "center"> <? echo $grade; ?> </td>
</tr>
<?
}?>
<table border="0">
<td><input type=button name=addtask value="NewTask" onclick="newAdd()"></td>
<td><input type=button name=updtask value="UpdateTask" onclick="reAdd()"></td>
<td><input type=submit name=deltask value="DeleteTask" onclick="del()" ></td>
</table>
</form> <script language ="javascript">
function newAdd()
{
window.location.href = "addtask.php";
}
function reAdd()
{
window.location.href = "updatetask.php";
}
function del()
{
form1.submit();
}
</script> </body>updatetask.php不能通过$_GET[]或$_POST[]取到“id[]”的值。
代码:
<?phpsession_start();if (empty($_SESSION['username'])) { echo "您还没有登录,不能访问当前页面!"; exit;}
?><body bgcolor="silver">
<form method= "POST" name="form1" action= "deletetask.php">
<?
require ("../include/conn.php");echo "<p><table border='1' cellspacing='1'><tr><th>选择</th><th>序号</th><th>任务描述</th><th>任务接收者</th><th>任务派发者</th><th>进度</th><th>开始日期</th><th>结束日期</th><th>等级</th><th>Display Detail</th></tr>";$sql="select * from task where (recipient='".$_SESSION['username']."' or distributer='".$_SESSION['username']."') and status<>1 order by grade desc,no desc";
$result=mysql_query($sql);while ($row=mysql_fetch_array($result)){
if ($row['grade']=='1')
$grade=str_replace('1','一般',$row['grade']);
else
$grade=str_replace('2','紧急',$row['grade']);
?>
<tr>
<td align = "center"> <input type="radio" name="id[]" value=<? echo ($row['id']); ?>></td>
<td align = "center"> <? echo ($row['no']); ?> </td>
<td align = "center"> <? echo ($row['describing']); ?> </td>
<td align = "center"> <? echo ($row['recipient']); ?> </td>
<td align = "center"> <? echo ($row['distributer']); ?> </td>
<td align = "center"> <? echo ($row['schedule']); ?> </td>
<td align = "center"> <? echo ($row['begindate']); ?> </td>
<td align = "center"> <? echo ($row['finishdate']); ?> </td>
<td align = "center"> <? echo $grade; ?> </td>
</tr>
<?
}?>
<table border="0">
<td><input type=button name=addtask value="NewTask" onclick="newAdd()"></td>
<td><input type=button name=updtask value="UpdateTask" onclick="reAdd()"></td>
<td><input type=submit name=deltask value="DeleteTask" onclick="del()" ></td>
</table>
</form> <script language ="javascript">
function newAdd()
{
window.location.href = "addtask.php";
}
function reAdd()
{
window.location.href = "updatetask.php";
}
function del()
{
form1.submit();
}
</script> </body>updatetask.php不能通过$_GET[]或$_POST[]取到“id[]”的值。
也不行。
病急乱投医啊!
?id[]=123时echo $_GET['id[]'];//取不到的
echo $_GET['id'][0];//能取到123
function newAdd(){
form1.action = "addtask.php";
form1.submit();
}function reAdd(){
form1.action = "updatetask.php";
form1.submit();
}
function del(){
//这个input本来就是submit的,所以是是多余的
//form1.submit();
}