随笔 - 78  文章 - 25  trackbacks - 0
<2013年8月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用链接

留言簿

随笔分类(75)

随笔档案(78)

相册

实用Links

我的Links

搜索

  •  

积分与排名

  • 积分 - 111819
  • 排名 - 519

最新评论

阅读排行榜

评论排行榜

deleteData.php 页面
<html>
    <head>
    </head>
    <body>
        <form name="frm" action="processDeleteData.php" method="post">
            <table border="1" align="center" cellspacing="0" cellpadding="0">
                <caption>学生一览表</caption>
                <th>选项</th>
                <th>学号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>地址</th>
                <?php
                    $link=mysql_connect("localhost","root","root");
                    mysql_select_db("rorely");
                    $exec="select * from test";
                    $result=mysql_query($exec);
                    while($rs=mysql_fetch_object($result)){
                        $id=$rs->id;
                        $name=$rs->name;
                        $age=$rs->age;
                        $sex=$rs->sex;
                        $address=$rs->address;                    
                ?>
                <tr align="center">
                    <td><input type="radio" name="del" value=<?php echo $id ?> /></td>
                    <td><?php echo $id ?></td>
                    <td><?php echo $name ?></td>
                    <td><?php echo $age ?></td>
                    <td><?php echo $sex ?></td>
                    <td><?php echo $address ?></td>
                </tr>
                <?php
                    }
                    mysql_close();
                ?>
            </table>
            <center><input type="submit" value="删除" /></center>
        </form>
    </body>
</html>

processDeleteData.php处理删除页面
<?php
    $link=mysql_connect("localhost","root","root");
    mysql_select_db("rorely");
    $id=$_POST['del'];
    $exec="delete from test where id=$id";
    $result=mysql_query($exec);
    if((mysql_affected_rows()==0)||(mysql_affected_rows()==-1))
        echo"没有找到记录,或者删除时产生错误!";
    else echo"学生已删除!";
    mysql_close();
?>
<a href="deleteData.php">返回删除页面</a>

posted on 2009-07-01 15:30 期待明天 阅读(5591) 评论(5)  编辑  收藏 所属分类: PHP

FeedBack:
# re: php 删除数据库表中的记录 2013-05-13 10:04 ghghh
nvcnvbn  回复  更多评论
  
# re: php 删除数据库表中的记录 2013-06-13 09:51 
恭恭敬敬恭恭敬敬恭恭敬敬恭恭敬敬恭恭敬敬恭恭敬敬工  回复  更多评论
  
# re: php 删除数据库表中的记录 2013-06-13 09:52 
@夺
压顶地奇才  回复  更多评论
  
# re: php 删除数据库表中的记录 2013-06-13 09:53 
@ghghh
3333  回复  更多评论
  
# re: php 删除数据库表中的记录 2013-08-19 16:59 换个
冎  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: