關于php讀取mysql數(shù)據(jù)庫代碼的信息
php鏈接代碼如下lt?php 設置編碼格式 headerquotContenttypetexthtmlcharset=utf8quot定義數(shù)據(jù)庫主機地址 host=quotlocalhostquot定義mysql數(shù)據(jù)庫登錄用戶名 user=quotrootquot定義mysql數(shù)據(jù)庫登錄密碼 pwd=quotquot。
connect#39數(shù)據(jù)庫地址#39,#39數(shù)據(jù)庫用戶名#39,#39數(shù)據(jù)庫密碼#39a=mysql_queryquotSELECT * FROM `數(shù)據(jù)庫名``表名`quotwhile$aa=mysql_fetch_array$a echo $aa#39要顯示的列#39#39#39 mysql_close。
讀取表 輸出表中數(shù)據(jù) 下面是代碼lt?php con = mysql_connectquotlocalhostquot,quotrootquot,quotabc123quot* localhost 是服務器 root 是用戶名 abc123 是密碼* if !$con diequot數(shù)據(jù)庫服務器連接失敗quot *。
1鏈接到MySQL數(shù)據(jù)庫在PHP中,可以使用mysqli或PDO擴展來連接到MySQL數(shù)據(jù)庫下面是一個使用mysqli擴展連接到數(shù)據(jù)庫的示例代碼`$servername=localhost$username=yourusername$password=yourpassword$dbname=yourdatabase。
掃描二維碼推送至手機訪問。
版權聲明:本文由飛速云SEO網絡優(yōu)化推廣發(fā)布,如需轉載請注明出處。