十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
我直接在這給你修改答案算了
創(chuàng)新互聯(lián)主營永城網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都App定制開發(fā),永城h5成都微信小程序搭建,永城網(wǎng)站營銷推廣歡迎永城等地區(qū)企業(yè)咨詢
使用的時候刪除行號 修改數(shù)據(jù)庫配置 如果想使用 頁面不刷新查詢數(shù)據(jù)庫 需要使用JQUERY 如果有需要給我留言
1 ?php
2 if(isset($_POST['submit'])$_POST['submit']=='提交'){
3 //判斷是否是提交過來的
4 $intext = $_POST['intext'];
5 if($intext!=null||$intext!=''){
6 $link = mysql_connect("localhost", "root", "123456");
7 //數(shù)據(jù)庫配置信息 第一個參數(shù)數(shù)據(jù)庫位置第二個是用戶名第三個是密碼
8 mysql_select_db("szn_test");
9 //設(shè)置要使用的數(shù)據(jù)庫
10 $sql = "select * from demo where res = '".$intext."'";
11 //SQL語句
12 var_dump($sql);
13 $res = mysql_query($sql);
14 $arr = array();
15 //吧結(jié)果存入數(shù)組 并記錄數(shù)組長度
16 $count = 0;
17 while($data = mysql_fetch_array($res)){
18 $arr[$count] = $data;
19 $count++;
20 }
21 //關(guān)閉數(shù)據(jù)庫
22 mysql_close($link);
23 }
24 }
25
26 ?
27 html
28 head
29 title/title
30 /head
31 body
32 form id="form1" method="post" action="demo.php"
33 input type="text" name="intext"
34 input type="submit" name="submit" value="提交"
35 /form
36 ?php
37 if(isset($arr)$arr != null){
38 for($i = 0; $i $count; $i++){
39 foreach($arr[$i] as $key = $value){
40 echo "key:".$key." value:".$value;
41 echo " ";
42 }
43 echo "br";
44 }
45 }
46 ?
47 /body
48 /html
這個是數(shù)據(jù)庫查詢代碼 你可以看以下對照著修改修改
?php
$sql?=?'select?count(*)?as?num?from?TableName';
$num?=?mysql_fetch_assoc(myslq_query($sql));#您可以簡化該查詢,如$db-XXX
$total?=?$num['num'];#$total即為行數(shù)
$sql = mysql_query("select * from 表名");
$row = mysql_num_rows($sql);
echo $row;
$goods = D('Goods');//實例化Model對象,實際操作Goods數(shù)據(jù)表
$info = $goods - select();//獲得數(shù)據(jù)信息
print_r($info);//打印信息
這個簡單啊!
首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看
!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編輯器、瀏覽器。
1、首先,打開php編輯器,新建php文件,例如:index.php。
2、在index.php中,輸入代碼:
$conn = new mysqli('10.5.15.177', 'root', '', 'test');
$sql = "select * from stu";
$r = $conn-query($sql);
print_r($r-num_rows);
3、瀏覽器運行index.php頁面,此時打印出了stu表的記錄數(shù)是5。