php數(shù)據(jù)表顯示 php表單顯示數(shù)據(jù)庫(kù)內(nèi)容

怎么用php顯示mysql 數(shù)據(jù)表數(shù)據(jù)

html

成都創(chuàng)新互聯(lián)專注于酉陽(yáng)土家族苗族網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供酉陽(yáng)土家族苗族營(yíng)銷型網(wǎng)站建設(shè),酉陽(yáng)土家族苗族網(wǎng)站制作、酉陽(yáng)土家族苗族網(wǎng)頁(yè)設(shè)計(jì)、酉陽(yáng)土家族苗族網(wǎng)站官網(wǎng)定制、微信小程序服務(wù),打造酉陽(yáng)土家族苗族網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供酉陽(yáng)土家族苗族網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

head

title瀏覽表中記錄/title

/head

body

center

?php

$db_host=localhost; //MYSQL服務(wù)器名

$db_user=root; //MYSQL用戶名

$db_pass=""; //MYSQL用戶對(duì)應(yīng)密碼

$db_name="test"; //要操作的數(shù)據(jù)庫(kù)

//使用mysql_connect()函數(shù)對(duì)服務(wù)器進(jìn)行連接,如果出錯(cuò)返回相應(yīng)信息

$link=mysql_connect($db_host,$db_user,$db_pass)or die("不能連接到服務(wù)器".mysql_error());

mysql_select_db($db_name,$link); //選擇相應(yīng)的數(shù)據(jù)庫(kù),這里選擇test庫(kù)

$sql="select * from test1"; //先執(zhí)行SQL語(yǔ)句顯示所有記錄以與插入后相比較

$result=mysql_query($sql,$link); //使用mysql_query()發(fā)送SQL請(qǐng)求

echo "當(dāng)前表中的記錄有:";

echo "table border=1"; //使用表格格式化數(shù)據(jù)

echo "trtdID/tdtd姓名/tdtd郵箱/tdtd電話/tdtd地址/td/tr";

while($row=mysql_fetch_array($result)) //遍歷SQL語(yǔ)句執(zhí)行結(jié)果把值賦給數(shù)組

{

echo "tr";

echo "td".$row[id]."/td"; //顯示ID

echo "td".$row[name]." /td"; //顯示姓名

echo "td".$row[mail]." /td"; //顯示郵箱

echo "td".$row[phone]." /td"; //顯示電話

echo "td".$row[address]." /td"; //顯示地址

echo "/tr";

}

echo "/table";

?

/center

/body

/html

PHP獲取sql數(shù)據(jù)表并顯示在頁(yè)面上

首先計(jì)算出總條數(shù),

$query = mysql_query("select * from my_lyb");

$maxclou = mysql_num_rows($query);

算出總頁(yè)數(shù),

$maxpage = ceil($maxclou/5);

用get方法獲得當(dāng)前頁(yè)(如果為空,默認(rèn)第一頁(yè)),算出上頁(yè) 下一頁(yè)

php如何查詢數(shù)據(jù)庫(kù)表中的數(shù)據(jù)并顯示

這個(gè)簡(jiǎn)單啊!

首頁(yè)做個(gè)前臺(tái)輸入姓名和會(huì)員卡信息的頁(yè)面,我做個(gè)簡(jiǎn)單的頁(yè)面給你看

!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"

html?xmlns="

head

meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/

title會(huì)員查詢系統(tǒng)/title

/head

body

form?id="form1"?name="form1"?method="post"?action="test.php"

p

label?for="name"/label

input?type="text"?name="name"?id="name"?/

/p

p

label?for="vipid"/label

input?type="text"?name="vipid"?id="vipid"?/

/p

p

input?type="submit"?name="button"?id="button"?value="查詢"?/

/p

/form

/body

/html

然后我給你一個(gè)test.php的文件代碼:

?php

$name????=????trim($_POST['name']);

$vipid????=????trim($_POST['vipid']);

$con?=?mysql_connect("127.0.0.1","數(shù)據(jù)庫(kù)用戶名","數(shù)據(jù)庫(kù)密碼");

if?(!$con)

{

die('Could?not?connect:?'?.?mysql_error());

}

$a????=????mysql_select_db("數(shù)據(jù)庫(kù)名字",?$con);

$sql????=????"select?*?from?kh_customer?where?name?=?'$name'?and?vipid?=?'$vipid'";

$result?=?mysql_query($sql);

while($row?=?mysql_fetch_array($result))

{

echo?$row['name']?.?"?"?.?$row['data'];

echo?"br?/";

}

mysql_close($con);

?

頁(yè)面美化自己去搞!只能幫你這么多了

當(dāng)前題目:php數(shù)據(jù)表顯示 php表單顯示數(shù)據(jù)庫(kù)內(nèi)容
文章分享:http://muchs.cn/article16/hphodg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣網(wǎng)站營(yíng)銷、建站公司、移動(dòng)網(wǎng)站建設(shè)用戶體驗(yàn)、營(yíng)銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)