php數(shù)據(jù)庫查詢所有數(shù)據(jù) php執(zhí)行數(shù)據(jù)庫查詢語句

php搜索查詢數(shù)據(jù)庫數(shù)據(jù)

查看一下代碼:

創(chuàng)新互聯(lián)公司是一家專業(yè)提供新和企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計(jì)、做網(wǎng)站H5高端網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為新和眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。

?php

//?獲取表單提交值

$student_id?=?intval(trim($_POST['student_id']));

//?頁面表單??可以放單獨(dú)的html文件中,如果放單獨(dú)的html頁面中?form?的action的地址要改成下面的PHP文件名

echo?'form?action=""?method="post"

input?type="text"?name="student_id"?value="{$student_id}"/

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

/form';

//?當(dāng)有數(shù)據(jù)提交時(shí)

if?($student_id)

{

$con=?mysql_connect("localhost","root","111")?or?die("連接錯(cuò)誤");

mysql_select_db("examination",$con);

//?查詢

$sql?=?"SELECT?*?FROM?tablename?WHERE?student_id?=?$student_id?";

$res=mysql_query($sql);

$row=mysql_fetch_array($res);

//?輸出

echo?'學(xué)號(hào):'.$row['student_id'].'br姓名:'.$row['name'].'br性別:'.$row['gender'].'br分?jǐn)?shù):'.$row['score'];

}

?

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

這個(gè)簡單??!

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

!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ù)庫用戶名","數(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查詢MYSQL的內(nèi)容,并輸出結(jié)果

1、用navicat新建一個(gè)數(shù)據(jù)庫database1。

2、在database1數(shù)據(jù)庫中新建一個(gè)表table2。

3、在table2中添加新的數(shù)據(jù),新建一個(gè)名稱為mysql_query的數(shù)據(jù)庫。

4、在頁面中用mysql_connect 函數(shù)與數(shù)據(jù)庫建立連接。

5、用mysql_select_db函數(shù)選擇要查詢的數(shù)據(jù)庫。

6、添加一個(gè)查詢 table2表的查詢語句“$sql=select * from table2“。

7、將查詢語句$sql添加到查詢數(shù)據(jù)庫函數(shù)mysql_query中,返回值賦值給變量query。

8、最后將mysql_query。php文件在瀏覽器中打開,查看查詢到數(shù)據(jù)庫中的內(nèi)容的結(jié)果。

當(dāng)前名稱:php數(shù)據(jù)庫查詢所有數(shù)據(jù) php執(zhí)行數(shù)據(jù)庫查詢語句
鏈接URL:http://muchs.cn/article44/hgishe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、品牌網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、網(wǎng)站導(dǎo)航、手機(jī)網(wǎng)站建設(shè)、Google

廣告

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

網(wǎng)站優(yōu)化排名