/*
//给大家带来php最基本的增删改查的方法,我的mysql数据库配置信息如下:
//主机IP:localhost
//用户名:root
//密码:123456
//数据库名:databaseTest
//表名:test(两个字段,id(int),name())
$id=1;
$name="zhangsan";
$con = mysql_connect("localhost","root","123456");
mysql_select_db("databaseTest", $con);
$sql="INSERT INTO test (id,name)
VALUES (‘".$id."‘,‘" .$name."‘)";
mysql_query($sql);
echo "操作已完成";
if ($con){mysql_close($con);}
//注意:sql语句不区分大小写,为了验证这一点,这部分sql语句的关键词我采用大写的,后面的采用小写的,在双引号内包裹的整个sql语句可以*换行,当然
//不能把完整的单词或字符串切断,还要注意字符串的拼接问题
//-----------------------查询刚刚插入的数据------------------------
$con = mysql_connect("localhost","root","123456");
mysql_select_db("databaseTest", $con);
$id=1;
$sql="select * from test where id=".$id;
$result=mysql_query($sql);//注意:如果此时直接打印$result,就会显示:Resource id #3,要用mysql_fetch_array()函数接收数据,该函数返回一个数组
$data=mysql_fetch_array($result);
echo var_dump($data);
if ($con){mysql_close($con);}
//--------------------------------------------------------------------------
//-----------------------修改刚刚插入的数据------------------------
$con = mysql_connect("localhost","root","123456");
mysql_select_db("databaseTest", $con);
$id=1;
$name="lisi";
$sql="update test set name=‘".$name."‘ where id=".$id;
mysql_query($sql);
echo "操作已完成";
if ($con){mysql_close($con);}
//-----------------------删除刚刚插入的数据------------------------
$con = mysql_connect("localhost","root","123456");
mysql_select_db("databaseTest", $con);
$id=1;
$sql="delete from test where id=".$id;
mysql_query($sql);
echo "操作已完成";
if ($con){mysql_close($con);}
//--------------------------------------------------------------------------
*/
?>