一般我們?yōu)榱藴p少數(shù)據(jù)庫鏈接,取數(shù)據(jù)是一次取出所有想要的數(shù)據(jù)然后做循御孝環(huán)處理,而不是一個個循環(huán)取出

創(chuàng)新互聯(lián)是專業(yè)的渭濱網(wǎng)站建設公司,渭濱接單;提供網(wǎng)站設計制作、網(wǎng)站設計,網(wǎng)頁設計,網(wǎng)站設計,建網(wǎng)站,PHP網(wǎng)站建設等專業(yè)做網(wǎng)站服務;采用PHP框架,可快速的進行渭濱網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
$servername?=?"localhost";
$username?=?"root";
$password?=?"root";
$dbname?=?"aaaa";
//?創(chuàng)建連接
$conn?=?new?mysqli($servername,?$username,?$password,?$dbname);
//?Check?connection
if?($conn-connect_error)?{
die("連接失敗:?"?.?$conn-connect_error);
}?
$conn-query('set?names?utf8'沒豎);
$sql?=?"SELECT?name?FROM?xiao?";//這鎮(zhèn)察稿里是查詢xiao表的name列的所有數(shù)據(jù)
$result?=?$conn-query($sql);
if?($result-num_rows??0)?{
//?輸出數(shù)據(jù)
while($row?=?$result-fetch_assoc())?{
//print_r($row);
echo?"name:?"?.?$row["name"]."br";//這里是循環(huán)打印
}
}?else?{
echo?"沒有查詢到數(shù)據(jù)";
}
$conn-close();
$str='admin=管理員system=系統(tǒng)user=用戶vip=會員you=你寬扒me=我';??//用于替慎喚昌換的字符串
parse_str($str,$arr);?
$arr=array_flip($arr);?
$con=mysqli_connect('localhost','root','root','test');???//用戶名,密碼,數(shù)據(jù)庫名自己修改
$a=mysqli_query($con,'select?*?from?a');?????????????????//表名也請自己修改,表是按照您的要求設計的
$html="table?border='1'?width='500'trtdID/tdtd?align='center'list/td/tr";
while($rel=mysqli_fetch_assoc($a)){
$item=explode(',',$rel['list']);
$item=array_filter($item);
$html=$html."tr";
$html=$html."td{$rel['ID']}/td";
鏈唯??foreach($item?as?$k=$v){
$b=array_search($v,$arr);
$str=$v;
$c=str_replace($str,$b,$str);
if($c=='')?$c='窗口';
$html=$html."tdinput?type='checkbox'?value='{$str}'?/{$c}/td";
}
$html."/tr";
}
$html.="/table";
echo?$html;
網(wǎng)頁名稱:php數(shù)據(jù)庫取數(shù)據(jù) php讀取數(shù)據(jù)庫內(nèi)容并輸出
當前網(wǎng)址:http://chinadenli.net/article1/dsphhid.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、虛擬主機、企業(yè)網(wǎng)站制作、商城網(wǎng)站、靜態(tài)網(wǎng)站、小程序開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)