21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
$myconn=mysql_connect("localhost","root","");
mysql_select_db("login_test",$myconn);
$strSql="select * from table_test";
$result=mysql_query($strSql,$myconn);
?>
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<form METHOD="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<?php
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td><?php echo $row['objname']?></td>
<td><?php echo $row['objinfo']?></td>
<td><input type="hidden" name="id" value="<?php echo $row['id']?>"><input type="submit" value="delete"/></td>
</tr>
<?php
}
?>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
</form>
<?php
echo empty($_POST);
/*if(!empty($_POST)){
$id = $_POST['id'];
$sql = "delete from student where objid='$id'";
$query = mysql_query($sql);
if($query){
echo "<script>alert('删除成功');history.back();</script>";
}
}*/
?>
</body>
<?php mysql_close($myconn); ?>
</html>
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<form METHOD="POST">
<tr>
<td>obj1</td>
<td>this is obj1</td>
<td><input type="hidden" name="id" value="1">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj2</td>
<td>this is obj2</td>
<td><input type="hidden" name="id" value="2">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj3</td>
<td>this is obj3</td>
<td><input type="hidden" name="id" value="3">
<input type="submit" value="delete"/></td>
</tr>
</form>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
1Array
(
)
</body>
</html>
[/quote]
额、、、 你while还是放form里面去吧。。。[/quote]
还是放里面才对吗?[/quote]
这么多form 看着不别扭。。。
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<form METHOD="POST">
<tr>
<td>obj1</td>
<td>this is obj1</td>
<td><input type="hidden" name="id" value="1">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj2</td>
<td>this is obj2</td>
<td><input type="hidden" name="id" value="2">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj3</td>
<td>this is obj3</td>
<td><input type="hidden" name="id" value="3">
<input type="submit" value="delete"/></td>
</tr>
</form>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
1Array
(
)
</body>
</html>
[/quote]
额、、、 你while还是放form里面去吧。。。[/quote]
还是放里面才对吗?
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<form METHOD="POST">
<tr>
<td>obj1</td>
<td>this is obj1</td>
<td><input type="hidden" name="id" value="1">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj2</td>
<td>this is obj2</td>
<td><input type="hidden" name="id" value="2">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj3</td>
<td>this is obj3</td>
<td><input type="hidden" name="id" value="3">
<input type="submit" value="delete"/></td>
</tr>
</form>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
1Array
(
)
</body>
</html>
[/quote]
额、、、 你while还是放form里面去吧。。。
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<form METHOD="POST">
<tr>
<td>obj1</td>
<td>this is obj1</td>
<td><input type="hidden" name="id" value="1">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj2</td>
<td>this is obj2</td>
<td><input type="hidden" name="id" value="2">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj3</td>
<td>this is obj3</td>
<td><input type="hidden" name="id" value="3">
<input type="submit" value="delete"/></td>
</tr>
</form>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
1Array
(
)
</body>
</html>
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<form METHOD="POST">
<tr>
<td>obj1</td>
<td>this is obj1</td>
<td><input type="hidden" name="id" value="<br />
<b>Notice</b>: Undefined index: id in <b>C:\xampp\htdocs\test2\test.php</b> on line <b>30</b><br />
">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj2</td>
<td>this is obj2</td>
<td><input type="hidden" name="id" value="<br />
<b>Notice</b>: Undefined index: id in <b>C:\xampp\htdocs\test2\test.php</b> on line <b>30</b><br />
">
<input type="submit" value="delete"/></td>
</tr>
</form>
<form METHOD="POST">
<tr>
<td>obj3</td>
<td>this is obj3</td>
<td><input type="hidden" name="id" value="<br />
<b>Notice</b>: Undefined index: id in <b>C:\xampp\htdocs\test2\test.php</b> on line <b>30</b><br />
">
<input type="submit" value="delete"/></td>
</tr>
</form>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
1Array
(
)
</body>
</html>
<?php
$myconn=mysql_connect("localhost","root","");
mysql_select_db("login_test",$myconn);
$strSql="select * from table_test";
$result=mysql_query($strSql,$myconn);
?>
<html>
<head>
<title>Print test</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br>
显示:
<br>
<table id="table1">
<tr class="table_head">
<td>objname</td>
<td>objinfo</td>
</tr>
<?php
while($row=mysql_fetch_array($result))
{
?>
<form METHOD="POST">
<tr>
<td><?php echo $row['objname']?></td>
<td><?php echo $row['objinfo']?></td>
<td><input type="hidden" name="id" value="<?php echo $row['id']?>">
<input type="submit" value="delete"/></td>
</tr>
</form>
<?php
}
?>
</table>
<div><a href="http://localhost/test2/submit.php">点此添加信息</a></div>
<?php
echo empty($_POST);
print_r($_POST);
/*if(!empty($_POST)){
$id = $_POST['id'];
$sql = "delete from student where objid='$id'";
$query = mysql_query($sql);
if($query){
echo "<script>alert('删除成功');history.back();</script>";
}
}*/
?>
</body>
<?php mysql_close($myconn); ?>
</html>
我改成这样以后 echo的post依然是空啊 是哪出问题了?