php數(shù)據(jù)顯示,PHP數(shù)據(jù)

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

這個簡單?。?/p>

創(chuàng)新互聯(lián)一直秉承“誠信做人,踏實做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個客戶多一個朋友!為您提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè)、成都網(wǎng)頁設(shè)計、微信平臺小程序開發(fā)、成都網(wǎng)站開發(fā)、成都網(wǎng)站制作、成都軟件開發(fā)、app軟件定制開發(fā)是成都本地專業(yè)的網(wǎng)站建設(shè)和網(wǎng)站設(shè)計公司,等你一起來見證!

首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看

!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會員查詢系統(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

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

?php

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

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

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

if?(!$con)

{

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

}

$a????=????mysql_select_db("數(shù)據(jù)庫名字",?$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);

?

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

如何正確理解PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)

1、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之 mysql_result()

mixed mysql_result(resource result_set, int row [,mixed field])

從result_set 的指定row 中獲取一個field 的數(shù)據(jù). 簡單但是效率低.

舉例:

$link1?=?@mysql_connect("server1",?

"webuser",?"password")?

or?die("Could?not?connect?

to?mysql?server!");

@mysql_select_db("company")?

or?die("Could?not?select?database!");

$query?=?"select?id,?name?

from?product?order?by?name";?

$result?=?mysql_query($query);

$id?=?mysql_result($result,?0,?"id");

$name?=?mysql_result($result,?0,?"name");

mysql_close();

注意,上述代碼只是輸出結(jié)果集中的第一條數(shù)據(jù)的字段值,如果要輸出所有記錄,需要循環(huán)處理.

for?($i?=?0;?$i?=?mysql_num_rows($result);?$i++)

{

$id?=?mysql_result($result,?0,?"id");

$name?=?mysql_result($result,?0,?"name");

echo?"Product:?$name?($id)";

}

注意,如果查詢字段名是別名,則mysql_result中就使用別名.

2、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_row()

array mysql_fetch_row(resource result_set)

從result_set中獲取整行,把數(shù)據(jù)放入數(shù)組中.

舉例(注意和list 的巧妙配合):

$query?=?"select?id,?

name?from?product?order?by?name";?

$result?=?mysql_query($query);

while(list($id,?$name)?

=?mysql_fetch_row($result))?{

echo?"Product:?$name?($id)";

}

3、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_array()

array mysql_fetch_array(resource result_set [,int result_type])

mysql_fetch_row()的增強版.

將result_set的每一行獲取為一個關(guān)聯(lián)數(shù)組或/和數(shù)值索引數(shù)組.

默認獲取兩種數(shù)組,result_type可以設(shè)置:

MYSQL_ASSOC:返回關(guān)聯(lián)數(shù)組,字段名=字段值?

MYSQL_NUM:返回數(shù)值索引數(shù)組.

MYSQL_BOTH:獲取兩種數(shù)組.因此每個字段可以按索引偏移引用,也可以按字段名引用.

舉例:

$query?=?"select?id,

name?from?product?order?by?name";

$result?=?mysql_query($query);

while($row?=?mysql_fetch_array

($result,?MYSQL_BOTH))?{?

$name?=?$row['name'];

//或者?$name?=?$row[1];

$name?=?$row['id'];

//或者?$name?=?$row[0];

echo?"Product:?$name?($id)";

}

4、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_assoc()

array mysql_fetch_assoc(resource result_set)

相當(dāng)于 mysql_fetch_array($result, MYSQL_ASSOC)

5、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_object()

object mysql_fetch_object(resource result_set)?

和mysql_fetch_array()功能一樣,不過返回的不是數(shù)組,而是一個對象.

舉例:

$query?=?"select?id,?name?

from?product?order?by?name";

$result?=?mysql_query($query);?

while($row?=?mysql_fetch_object

($result))?{

$name?=?$row-name;

$name?=?$row-id;

echo?"Product:?$name?($id)";

}

以上這些函數(shù)就是PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)的全部總結(jié)。

PHP如何讓數(shù)據(jù)倒序顯示?

有兩種方法:

1、如果直接是字符串或者是數(shù)組,分別用strrev 或者array_reverse反轉(zhuǎn)可以

2、自己寫一個算法,讓字符串反轉(zhuǎn)過來。$str = "abcdef";for ($i=1; $i=strlen($str); $i++){

echo substr($str , -$i , 1)}。

php 正序輸出示例代碼

實現(xiàn)代碼:

// 正序

foreach($files as $file_num = $file) {

if(is_file($directory.$file)){

//$file = iconv("gb2312","UTF-8",$file); //或者 iconv("gb2312","UTF-8",$value);

$date = substr($file,0,9);

echo 'li class="world-cup-'.$date.'"';

echo 'a href="'.$directory.$file.'" rel="worldcup" title="巴西世界杯賽事'.$date.'"';

echo 'img src="'.$directory.$file.'" alt=""';

echo '/a';

echo '/li';

}

}

PHP如何查詢數(shù)據(jù)并顯示結(jié)果。

這個簡單??!

首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看

!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會員查詢系統(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

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

?php

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

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

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

if?(!$con)

{

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

}

$a????=????mysql_select_db("數(shù)據(jù)庫名字",?$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);

?

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

如何用php獲取數(shù)據(jù)庫信息并顯示

獲取ppq數(shù)據(jù)庫的所有表名的代碼:

?php

$server='localhost';

$user='root';

$pass='12345';

$dbname='ppq';

$conn=mysql_connect($server,$user,$pass);

if(!$conn)

die("數(shù)據(jù)庫系統(tǒng)連接失敗!");

$result=mysql_list_tables($dbname);

if(!$result)

die("數(shù)據(jù)庫連接失??!");

while($row=mysql_fetch_row($result))

{

echo

$row[0]."

";

}

mysql_free_result($result);

?

mysql_list_tables

(PHP

3,

PHP

4

,

PHP

5)

mysql_list_tables

--

列出

MySQL

數(shù)據(jù)庫中的表

說明

resource

mysql_list_tables

(

string

database

[,

resource

link_identifier])

mysql_list_tables()

接受一個數(shù)據(jù)庫名并返回和

mysql_query()

函數(shù)很相似的一個結(jié)果指針。用

mysql_fetch_array()或者用mysql_fetch_row()來獲得一個數(shù)組,數(shù)組的第0列就是數(shù)組名,當(dāng)獲取不到時

mysql_fetch_array()或者用mysql_fetch_row()返回

FALSE。

php查詢數(shù)據(jù)顯示問題

?php else{

echo "無數(shù)據(jù)";

}

這里好像有問題,else這里換行試下,其他代碼片段太少,你先試試這個

?php

else{

echo "無數(shù)據(jù)";

}

標(biāo)題名稱:php數(shù)據(jù)顯示,PHP數(shù)據(jù)
網(wǎng)站路徑:http://www.muchs.cn/article4/hcpjie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、品牌網(wǎng)站建設(shè)品牌網(wǎng)站設(shè)計、網(wǎng)站營銷、自適應(yīng)網(wǎng)站網(wǎng)站改版

廣告

聲明:本網(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)

網(wǎng)站托管運營