新聞中心
php怎么獲取數(shù)據(jù)表中內(nèi)容
?php
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、網(wǎng)站空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、潮陽(yáng)網(wǎng)站維護(hù)、網(wǎng)站推廣。
//打印出來(lái)的是對(duì)象object直接調(diào)用屬性即可
$name?=?$diy-info-name;
如有疑問(wèn),請(qǐng)追加
用PHP代碼如何查詢數(shù)據(jù)庫(kù)表中的一條記錄
我直接在這給你修改答案算了
使用的時(shí)候刪除行號(hào)
修改數(shù)據(jù)庫(kù)配置
如果想使用
頁(yè)面不刷新查詢數(shù)據(jù)庫(kù)
需要使用JQUERY
如果有需要給我留言
1
?php
2
if(isset($_POST['submit'])$_POST['submit']=='提交'){
3
//判斷是否是提交過(guò)來(lái)的
4
$intext
=
$_POST['intext'];
5
if($intext!=null||$intext!=''){
6
$link
=
mysql_connect("localhost",
"root",
"123456");
7
//數(shù)據(jù)庫(kù)配置信息
第一個(gè)參數(shù)數(shù)據(jù)庫(kù)位置第二個(gè)是用戶名第三個(gè)是密碼
8
mysql_select_db("szn_test");
9
//設(shè)置要使用的數(shù)據(jù)庫(kù)
10
$sql
=
"select
*
from
demo
where
res
=
'".$intext."'";
11
//SQL語(yǔ)句
12
var_dump($sql);
13
$res
=
mysql_query($sql);
14
$arr
=
array();
15
//吧結(jié)果存入數(shù)組
并記錄數(shù)組長(zhǎng)度
16
$count
=
0;
17
while($data
=
mysql_fetch_array($res)){
18
$arr[$count]
=
$data;
19
$count++;
20
}
21
//關(guān)閉數(shù)據(jù)庫(kù)
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
這個(gè)是數(shù)據(jù)庫(kù)查詢代碼
你可以看以下對(duì)照著修改修改
PHP 查詢兩個(gè)表數(shù)據(jù)
樓下幾位都對(duì)。但是你這表其實(shí)不太合理,兩張表的關(guān)聯(lián)有問(wèn)題。因?yàn)樯碳颐赡芟嗤ㄗh你加個(gè)字段shangjiaID 。table1 和table2中都有,且唯一。然后用左鏈接。left join 。不明白啥意思可以去百度下。
PHP 如何從一個(gè)表里連接查詢出另一個(gè)表內(nèi)的數(shù)據(jù)
//A表m的值
$m = 1;
$result = mysql_query("select n from B where x in(select x from A where m={$m})");
$rs = mysql_fetch_assoc($result);
$n = $rs['n'];
//B表n的值
echo $n;
php獲取表中所有查詢出來(lái)的結(jié)果數(shù)據(jù)
通過(guò)for循環(huán)
$sql=mysql_query("select?*?from?表名?where?name=張三“)
for($i=0;$imysql_num_rows($sql);$i++){
$result[$i]?=?mysql_fetch_assoc($sql);
}
臨時(shí)寫(xiě)的,比較匆忙??梢宰约嚎纯?。
mysql_num_rows是獲取一同有多少條數(shù)據(jù)
mysql_fetch_assoc和mysql_fetch_array差不多,自己查
php如何查詢數(shù)據(jù)庫(kù)表中的數(shù)據(jù)并顯示
這個(gè)簡(jiǎn)單啊!
首頁(yè)做個(gè)前臺(tái)輸入姓名和會(huì)員卡信息的頁(yè)面,我做個(gè)簡(jiǎn)單的頁(yè)面給你看
!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ù)庫(kù)用戶名","數(shù)據(jù)庫(kù)密碼");
if?(!$con)
{
die('Could?not?connect:?'?.?mysql_error());
}
$a????=????mysql_select_db("數(shù)據(jù)庫(kù)名字",?$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);
?
頁(yè)面美化自己去搞!只能幫你這么多了
本文標(biāo)題:php查詢表中數(shù)據(jù) php查詢sql數(shù)據(jù)并顯示
當(dāng)前URL:http://fisionsoft.com.cn/article/doddede.html