php簡單的操作數(shù)據(jù)庫

//1,連接數(shù)據(jù)庫?
$conn = mysql_connect(‘localhost’,’root’,’root’);?
if(!$conn){?
die(“連接失敗”.mysql_error);?
}?

//2,選擇數(shù)據(jù)庫?
mysql_select_db(“test”);?

//3,發(fā)送操作語句?
$sql=”select * from user”;?

//4,接收結(jié)果?
$res=mysql_query($sql,$conn);?

//5,遍歷結(jié)果?
while($row=mysql_fetch_row($res)){?
echo “
$row[0]–$row[1]–$row[2]”;?
}?

??????? //6,關(guān)閉?
??????? mysql_free_result($res);?
??????? mysql_close($conn);?

?>

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊12 分享