php用sqlserver數(shù)據(jù)庫(kù) php查詢數(shù)據(jù)庫(kù)sql拼接方法是什么?
php查詢數(shù)據(jù)庫(kù)sql拼接方法是什么?操作步驟:1.連接數(shù)據(jù)庫(kù);2.sql語(yǔ)句;3.執(zhí)行查詢4.在頁(yè)面上遍歷展示<?php?//mysql主機(jī)地址$host?=?"localhost"http://m
php查詢數(shù)據(jù)庫(kù)sql拼接方法是什么?
操作步驟:
1.連接數(shù)據(jù)庫(kù);
2.sql語(yǔ)句;
3.執(zhí)行查詢4.在頁(yè)面上遍歷展示<?php?//mysql主機(jī)地址$host?=?"localhost"http://mysql用戶名$user?=?"root"http://mysql登錄密碼$pswd?=?"root"http://鏈接數(shù)據(jù)庫(kù)$conn?=?mysql_connect($host,$user,$pswd)if(!$conn){????die("數(shù)據(jù)庫(kù)連接失??!")}//設(shè)置數(shù)據(jù)庫(kù)操作編碼,防止亂碼mysql_query("set?names?"utf8"")?//選擇要操作的數(shù)據(jù)庫(kù)mysql_select_db("testdb")//sql語(yǔ)句$sql?=?"select?*?from?uses"http://執(zhí)行sql?$result=mysql_query($sql)??//循環(huán)遍歷然后展示while($row?=?mysql_fetch_array($result)){????echo?$row[0]."=="????echo?$row[1]."=="????echo?$row[2]."<br/>"}?>