Home > php教程 > php手册 > PHP学习笔记-数据库操作

PHP学习笔记-数据库操作

WBOY
Release: 2016-06-21 09:05:50
Original
755 people have browsed it

笔记|数据|数据库

$conn = mysql_connect("127.0.0.1","root","");  //连接MYSQL数据库
mysql_select_db("temp");  //选择数据库
$exec="select * from wind"; //选择数据表
$result = mysql_query($exec);  //执行记录
while ($rs=mysql_fetch_object($result))
{
 echo "姓名:".$rs->name."
";//等于rs.name
 echo "电话:".$rs->tel."
";
 echo "地址:".$rs->addr."

";
}
?>


用户名:

电  话:

地  址:




========处理页

$conn = mysql_connect("127.0.0.1","root","");  //连接MYSQL数据库
mysql_select_db("temp");  //选择数据库
$sql = "insert into wind(name,tel,addr)values('".$_POST['name']."','".$_POST['tel']."','".$_POST['addr']."')";
//删除,修改只需改$sql语句即可
//删除 $sql ="delete from wind where......"
//修改 $sql = "update wind set item1='".$_POST['item1']."' where ...";
$rs1 = mysql_query($sql);
echo "数据插入成功!";
echo"<script>location.href('day2.php');</script>";
?>



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template