php+mysql操作MYSQL中数据库的记录集(添加、修改、更新、查询)

1 view
Skip to first unread message

love0...@gmail.com

unread,
Mar 21, 2006, 11:53:48 PM3/21/06
to 52info
<?php
mysql_connect("localhost", "root", "windows") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
mysql_query("create database php");

///////////////////////////////选择PHP数据库并向数据库里添加表usr///////////////////////////////////////
mysql_select_db("php");

mysql_query("create table usr(id int ,name char)");

/////////////////////////往usr表里添加一记录////////////////////////////////////

mysql_select_db("php");
mysql_query('insert into usr(id,name) values(1,4)');

/////////////////////修改usr表里指定记录///////////////////////////////////////

mysql_select_db("php");
mysql_query("update usr set name=3 where id='123'");


///////////////////////把表中所有ID=123的用户名改为3////////////////////////////////


////////////////////删除usr表里指定记录//////////////////////////////////////////////////////
mysql_select_db("php");
mysql_query("delete from usr where name=3");
///////////////////删除usr表中NAME=3的记录///////////////////////////////////////////
?>

Reply all
Reply to author
Forward
0 new messages