寫個(gè)function呀,調(diào)用function顯示數(shù)據(jù)。
成都創(chuàng)新互聯(lián)于2013年創(chuàng)立,先為嵩縣等服務(wù)建站,嵩縣等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為嵩縣企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
我給你舉個(gè)例子你看下:吧下面的代碼粘貼運(yùn)行,您就會(huì)秒懂:
html
head
/head
body?
?php
$name?=?$email?=?$gender?=?$comment?=?$website?=?"";
if?($_SERVER["REQUEST_METHOD"]?==?"POST")?{
$name?=?test_input($_POST["name"]);
$email?=?test_input($_POST["email"]);
$website?=?test_input($_POST["website"]);
$comment?=?test_input($_POST["comment"]);
$gender?=?test_input($_POST["gender"]);
}
function?test_input($data)?{
$data?=?trim($data);
$data?=?stripslashes($data);
$data?=?htmlspecialchars($data);
return?$data;
}
?
h2PHP?驗(yàn)證實(shí)例/h2
form?method="post"?action="?php?echo?htmlspecialchars($_SERVER["PHP_SELF"]);?"
姓名:input?type="text"?name="name"
brbr
電郵:input?type="text"?name="email"
brbr
網(wǎng)址:input?type="text"?name="website"
brbr
評(píng)論:textarea?name="comment"?rows="5"?cols="40"/textarea
brbr
性別:
input?type="radio"?name="gender"?value="female"女性
input?type="radio"?name="gender"?value="male"男性
brbr
input?type="submit"?name="submit"?value="提交"
/form
?php
echo?"h2您的輸入:/h2";
echo?$name;
echo?"br";
echo?$email;
echo?"br";
echo?$website;
echo?"br";
echo?$comment;
echo?"br";
echo?$gender;
?
/body
/html
這個(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);
?
頁面美化自己去搞!只能幫你這么多了
會(huì)用jquery嗎,以jquery來講解:
原理是使用AJAX,很多JS庫都支持,如果是自己寫AJAX功能的話,請(qǐng)繼續(xù)提問,下面是以jquery舉例:
HTML按鈕部分:以文字為例:
htmlhead
script src="請(qǐng)加載jquery庫"/script
/headbody
input type="button" value="冰火裂紋" /
script
$("input").click(function(){ //下面的resopns是服務(wù)返回的內(nèi)容,加入返回內(nèi)容是【vaps2010】
$.post("test.php",{obj:something},function(respons){
$("input").attr("value",respons);
});
});
/script
/body
此段代碼運(yùn)行后,屏幕上出現(xiàn)是一個(gè)內(nèi)容為【冰火裂紋】的按鈕,點(diǎn)擊按鈕后,則按鈕變?yōu)椤緑aps2010】。
請(qǐng)記得采納??!
form action="" method="get"
請(qǐng)輸入ID號(hào):input type="text" name="word" /
input type="submit" value="查詢" /
/form
?php
if(!($_GET["word"])){
exit();//沒有數(shù)據(jù)
}
mysql_connect("127.0.0.1",用戶名,密碼);
$sql="use fenzu
select * from think_user
where id={$_GET['word']}
";
$rs=mysql_query($sql);
$num=mysql_num_rows($rs);
//獲取影響行數(shù),0表示沒查到
if(!($num)){
echo '數(shù)據(jù)不存在!';
}
$row=mysql_fetch_array($rs);//如果有多條數(shù)據(jù)請(qǐng)用循環(huán)
echo "id:{$row['id']}";
echo "名字:{$row['name']}";
echo "時(shí)間:{$row['time']}";
//手機(jī)打的沒測(cè)試過,應(yīng)該沒什么問題
?
在頁面上做一個(gè)點(diǎn)擊按鈕,然后使用ajax去請(qǐng)求數(shù)據(jù) php根據(jù)ajax傳過來的參數(shù)查詢所需的數(shù)據(jù)返回 js接收到數(shù)據(jù)在頁面上顯示。如果數(shù)據(jù)固定也可以在將查好的數(shù)據(jù)賦值給js變量進(jìn)行操作。
你的意思是說
點(diǎn)擊查詢后
要吧與關(guān)鍵字相關(guān)聯(lián)的整條記錄都顯示出來?
那樣的話
你要先把這條記錄復(fù)制
給某個(gè)數(shù)組,然后輸出這個(gè)數(shù)組就可以了
$sql="select
*
from
db1
where
name=$_post[name]";
$result=mysql_query($sql,$con);
$row=mysql_fetch_array($result)
echo
$row[name];
echo
$row[age];
……
當(dāng)前名稱:php點(diǎn)擊按鈕查詢數(shù)據(jù)庫 php實(shí)現(xiàn)簡單的查詢功能
轉(zhuǎn)載來源:http://muchs.cn/article40/hgegho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、ChatGPT、自適應(yīng)網(wǎng)站、網(wǎng)站內(nèi)鏈、面包屑導(dǎo)航、網(wǎng)站導(dǎo)航
聲明:本網(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í)需注明來源: 創(chuàng)新互聯(lián)