十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊
量身定制 + 運營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
查看一下代碼:

創(chuàng)新互聯(lián)公司是一家專業(yè)提供新和企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計、做網(wǎng)站、H5高端網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為新和眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。
?php
//?獲取表單提交值
$student_id?=?intval(trim($_POST['student_id']));
//?頁面表單??可以放單獨的html文件中,如果放單獨的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ù)提交時
if?($student_id)
{
$con=?mysql_connect("localhost","root","111")?or?die("連接錯誤");
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é)號:'.$row['student_id'].'br姓名:'.$row['name'].'br性別:'.$row['gender'].'br分?jǐn)?shù):'.$row['score'];
}
?
這個簡單啊!
首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看
!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);
?
頁面美化自己去搞!只能幫你這么多了
1、用navicat新建一個數(shù)據(jù)庫database1。
2、在database1數(shù)據(jù)庫中新建一個表table2。
3、在table2中添加新的數(shù)據(jù),新建一個名稱為mysql_query的數(shù)據(jù)庫。
4、在頁面中用mysql_connect 函數(shù)與數(shù)據(jù)庫建立連接。
5、用mysql_select_db函數(shù)選擇要查詢的數(shù)據(jù)庫。
6、添加一個查詢 table2表的查詢語句“$sql=select * from table2“。
7、將查詢語句$sql添加到查詢數(shù)據(jù)庫函數(shù)mysql_query中,返回值賦值給變量query。
8、最后將mysql_query。php文件在瀏覽器中打開,查看查詢到數(shù)據(jù)庫中的內(nèi)容的結(jié)果。