<?php
//链接mysql数据库
mysql_connect('localhost','root','123');
//选择当前的数据库
mysql_select_db('vilytestdb');
//在当前数据库执行 sql 语句
$query = "select * from students";
$result = mysql_query($query);
//操作查询返回的数据集
$index = 0;
while(
$student=mysql_fetch_array($result)
){
echo '<pre> '.$index.':<br/>';
print_r($student);
$index++;
}
echo '</pre>';
if(
mysql_close()
){
echo '<br/>关闭当前的数据库连接操作成功';
}else{
echo '<br/>关闭当前的数据库连接操作失败';
}
?>
转载于:https://www.cnblogs.com/vilyLei/articles/1578878.html