注册 登录
编程论坛 ASP技术论坛

新人 帮我写下 剩下不会写了 php删除

yc4360595 发布于 2011-09-16 19:04, 659 次点击
<body>
<table summary="This table shows the years 2004 through 2007"border="2">
<caption>输出</caption>
<tr>
   
    <th scope="col">Id</th>
    <th scope="col">名字</th>
    <th scope="col">城市</th>
    <th scope="col">性别</th>
    <th scope="col">生日</th>
    <th scope="col">操作</th>
</tr>
<form     method="post"    action="#"    ></form>

<?php


$hostname="127.0.0.1";
$username="root";
$password="123456";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db("test2");
$sql2="select * from yc1";
$result1=mysql_query($sql2);
$id=0;
$sql="delete from yc1 where=$id";
while($row=mysql_fetch_array($result1)){

?>
<tr>
    <th scope="col"><?php echo $row['id']?> </th>   
    <th scope="col"><?php echo $row['name']?> </th>
    <th scope="col"><?php echo $row['city'] ?></th>
    <th scope="col"><?php echo $row['sex'] ?></th>
    <th scope="col"><?php echo $row['birth'] ?></th>
    <th><input type="submit"    value="删除"        name="$id"/></th>

???
???
??
接下来 怎么写啊····急啊  各位大侠 帮下我
4 回复
#2
yc43605952011-09-17 07:33
   怎么 没人理我啊·····
光是 看的    哎········
#3
dzt00012011-09-17 08:17
发错版块了!
#4
gdk20062011-09-17 16:13
PHP 删除,很简单的事情啊。
@mysql_query("delete from news where id in ($P_ID)");

楼主的删除代码有问题。
#5
gdk20062011-09-17 16:16
<body>
<table summary="This table shows the years 2004 through 2007"border="2">
<caption>输出</caption>
<tr>
   
    <th scope="col">Id</th>
    <th scope="col">名字</th>
    <th scope="col">城市</th>
    <th scope="col">性别</th>
    <th scope="col">生日</th>
    <th scope="col">操作</th>
</tr>
<form     method="post"    action="#"    ></form>

<?php


$hostname="127.0.0.1";
$username="root";
$password="123456";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db("test2");

$act=$_REQUEST["act"];
$id = intval($_REQUEST["act"]);
if($act=="del")
{
    //执行删除程序
    @mysql_query("delete from yc1 where id in ($id)");
   
    //转向到列表页面.代码自己写
   
}

$sql2="select * from yc1";
$result1=mysql_query($sql2);


while($row=mysql_fetch_array($result1)){
?>
<tr>
    <th scope="col"><?php echo $row['id']?> </th>   
    <th scope="col"><?php echo $row['name']?> </th>
    <th scope="col"><?php echo $row['city'] ?></th>
    <th scope="col"><?php echo $row['sex'] ?></th>
    <th scope="col"><?php echo $row['birth'] ?></th>
    <th><a href="?id=<?=$row['id']?>&act=del" onClick="return confirm('是否将此信息删除?\n\n请您务必确认!')">删除</a></th>
1