WEB开发网
开发学院数据库MySQL php 对 mysql数据库的增,删,查 阅读

php 对 mysql数据库的增,删,查

 2012-10-19 13:59:50 来源:WEB开发网   
核心提示: $dbhost="localhost";$dbuser ="lch";$dbpass ="123456";$dbname = "lch_lvtone2";$conn = mysql_connect($dbhost,$dbuser,$

  $dbhost="localhost";
$dbuser ="lch";
$dbpass ="123456";
$dbname = "lch_lvtone2";
$conn = mysql_connect($dbhost,$dbuser,$dbpass,$dbname);

if($conn)
{
echo "connect";
}else
{
echo "11111";
}
mysql_select_db($dbname,$conn);
$sql = "insert into ";
$sql .="user(tripal_id,company_id,username,email,name,credit,parent_id,password,settle_password,lognum,last_login,new_fan_num,remember_me_num,
is_admin,is_b2b,is_b2c)";

$sql .="values('1','1','name3','1@qq.com','ling','23','0',null,null,'1','2012-10-18 16:25:39','1','1','1','1','1')";

mysql_query($sql) or die('insert data failed cause: '.mysql_error());

$select = "select * from user ";
$result = mysql_query($select) or die('select data failed cause: '.mysql_error());
print_r(mysql_fetch_array($result));

$update = "update user set email = '2@QQ.com' where id =3";
echo $update;
mysql_query($update) or die('update data failed cause: '.mysql_error());


$delete = "delete from user where id = 1";
mysql_query($delete) or die('delete data failed cause: '.mysql_error());

Tags:php mysql 数据库

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接