久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php怎么查詢mysql數(shù)據(jù)顯示

      php查詢mysql數(shù)據(jù)顯示的方法:1、連接數(shù)據(jù)庫服務(wù)器;2、設(shè)置字符集,使頁面編碼與數(shù)據(jù)庫編碼一致;3、定義數(shù)據(jù)庫命令查詢;4、執(zhí)行數(shù)據(jù)庫記錄;5、顯示數(shù)據(jù)結(jié)果即可。

      php怎么查詢mysql數(shù)據(jù)顯示

      本文操作環(huán)境:windows7系統(tǒng)、PHP7.1版,DELL G3電腦

      php怎么查詢mysql數(shù)據(jù)顯示?

      PHP+MYSQL進(jìn)行數(shù)據(jù)庫查詢

      一、基本代碼

      mysql_connect():用來建立和MYSQL數(shù)據(jù)庫連接的,共有5個(gè)參數(shù),通常情況下只用前3個(gè)參數(shù)。3個(gè)參數(shù)分別是MySQL服務(wù)器地址、用戶名和密碼。

      mysql_select_db():用來指定要操作的數(shù)據(jù)庫。如果要操作的數(shù)據(jù)庫還沒有創(chuàng)建,則要先創(chuàng)建數(shù)據(jù)庫,接著再創(chuàng)建數(shù)據(jù)庫中的表。

      mysql_query():查詢指令的專用函數(shù),所有的SQL語句都通過它執(zhí)行,并返回結(jié)果集。

      mysql_fetch_row():從結(jié)果集中取一行作為枚舉數(shù)據(jù),從和指定的結(jié)果標(biāo)識(shí)關(guān)聯(lián)的結(jié)果集中取得一行數(shù)據(jù)并作為數(shù)組返回。

      mysql_fetch_array():從結(jié)果集中取得一行作為關(guān)聯(lián)數(shù)組,或數(shù)字?jǐn)?shù)組,或二者兼有,除了將數(shù)據(jù)以數(shù)字索引方式儲(chǔ)存在數(shù)組中之外,還可以將數(shù)據(jù)作為關(guān)聯(lián)索引儲(chǔ)存,用字段名作為鍵名。

      mysql_fetch_object():從結(jié)果集中取得一行作為對(duì)象,并將字段名字做為屬性。

      mysql_fetch_assoc():從結(jié)果集中取得一行作為關(guān)聯(lián)數(shù)組,也就是說這個(gè)函數(shù)不能像mysql_fetch_row那樣用索引來取值,只能用字段名字來取。

      mysql_num_rows():獲取由select語句查詢到的結(jié)果集中行的數(shù)目

      二、示例

      <?php     /* 連接數(shù)據(jù)庫服務(wù)器,用or die的目的為了即使連接錯(cuò)誤,系統(tǒng)不會(huì)繼續(xù)執(zhí)行,而是返回錯(cuò)誤*/     $link=mysql_connect("localhost","root","12345678") or die("數(shù)據(jù)庫連接失敗");       /* 連接數(shù)據(jù)庫*/       mysql_select_db("phptest",$link);       /*設(shè)置字符集,使得頁面的編碼與數(shù)據(jù)庫的編碼一致。如果不一致將出現(xiàn)中文亂碼*/       mysql_query("set names utf8");       /*定義數(shù)據(jù)庫命令查詢*/       $q="select*from tb_user";       /*執(zhí)行數(shù)據(jù)庫查詢*/       $result=mysql_query($q);       /*執(zhí)行數(shù)據(jù)庫記錄*/       while($row=mysql_fetch_assoc($result)){           echo "<tr><td>".$row["id"]."</td><td>".$row["username"]."</td><td>".$row["password"]."</td></tr>";              /*顯示數(shù)據(jù)結(jié)果*/       } ?>

      三、實(shí)例

      PHP頁面querytest.php

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標(biāo)題文檔</title> </head> <body> <div> <center><table style="border:dashed;border-color:#CC99CC"> <tr style="background-color:#99FF33"> <td>序號(hào)</td> <td>用戶名</td> <td>密碼</td> </tr> <?php     /* 連接數(shù)據(jù)庫服務(wù)器,用or die的目的為了即使連接錯(cuò)誤,系統(tǒng)不會(huì)繼續(xù)執(zhí)行,而是返回錯(cuò)誤*/     $link=mysql_connect("localhost","root","12345678") or die("數(shù)據(jù)庫連接失敗");       /* 連接數(shù)據(jù)庫*/       mysql_select_db("phptest",$link);       /*設(shè)置字符集,使得頁面的編碼與數(shù)據(jù)庫的編碼一致。如果不一致將出現(xiàn)中文亂碼*/       mysql_query("set names utf8");       /*定義數(shù)據(jù)庫命令查詢*/       $q="select*from tb_user";       /*執(zhí)行數(shù)據(jù)庫查詢*/       $result=mysql_query($q);       /*執(zhí)行數(shù)據(jù)庫記錄*/       while($row=mysql_fetch_assoc($result)){           echo "<tr><td>".$row["id"]."</td><td>".$row["username"]."</td><td>".$row["password"]."</td></tr>";              /*顯示數(shù)據(jù)結(jié)果*/       } ?> </table> </center> </div> </body> </html>

      推薦學(xué)習(xí):《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)