Home  >  Article  >  php教程  >  php php 删除mysql 记录教程

php php 删除mysql 记录教程

WBOY
WBOYOriginal
2016-06-08 17:30:051073browse

我们用php 删除mysql里面的数据代码,这个实例很简单根据用户输入的或提交的信息来查找数据库合条件的信息进行删除

<script>ec(2);</script>

//连接数据库
$link_id = mysql_connect("localhost","root","") or die("连接失败");
if($link_id)
{
 mysql_select_db("my_test");
 if(!$_GET[id])
 {

  $result=mysql_query("select * from userinfo");
  echo "


    
     
     
     
     
     
     
    ";

 

  while($row=mysql_fetch_array($result)){
   echo "


     
     
     
     
     
     
    ";
  }
  echo "
编号 用户名称 性别 年龄 注册时间 操作
".$row[id]." ".$row[username]." ".$row[gender]." ".$row[age]." ".$row[regdate]." 删除
";

 }//显示列表的内容
 else
 {

   $sql="delete from userinfo where id=".$_GET[id];
   $result=mysql_query($sql);
   if($result)
    echo "记录已经成功删除www.111cn.net
返回";
   else
    echo "记录删除失败
返回";

 }//else($id部分)
} // end if
?>
www.111cn.net

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP 函数入门教程Next article:php图片计数器代码