$hostname="123456";
$username="123456";
$password="123456";
$database="123456";
$dbdriver="mysql";
//链接数据库
$conn = mysql_connect($hostname,$username,$password);
if(!$conn)
{
die("数据库链接失败:".mysql_error());
}
mysql_select_db("phzl",$conn);
print "数据库链接成功!!!
";
//查询数据库中的数据
$result = mysql_query("select * from student");
while($row = mysql_fetch_array($result))
{
print $row['firstname']." ".$row['lastname'];
print "
";
}
print "====================================";
print "
";
print "下面为条件查询。。。。。。";
print "
";
$res= mysql_query("select * from student where firstname='wang'");
while($row = mysql_fetch_array($res))
{
print $row['firstname']." ".$row['lastname'];
print "
";
}
/*
//数据库中插入数据
$sql =mysql_query("insert into student(id,FirstName,LastName)VALUE ('3','peter','pt')");
$sqll =mysql_query("insert into student(id,FirstName,LastName)VALUE ('4','Lili','Li')");
mysql_close();
*/
领取专属 10元无门槛券
私享最新 技术干货