php基本的鏈接mysql數(shù)據(jù)庫在函數(shù)為
$c = mysql_connect("localhost","root","password");連上數(shù)據(jù)庫后,選擇數(shù)據(jù)庫
$db = mysql_select_db('you_db'); //數(shù)據(jù)庫的名稱查詢數(shù)據(jù)庫,及打印數(shù)據(jù)
$sql = "select * from you_table ";
$res = mysql_query($sql);
if (!$res) {
die("could get the res:\n" . mysql_error());
}
while ($row = mysql_fetch_assoc($res)) {
print_r($row);
}關(guān)閉打開的數(shù)據(jù)庫
mysql_close($con);
