php查找多條數(shù)據(jù)庫(kù) php篩選查詢(xún)數(shù)據(jù)庫(kù)

ThinkPhp中,我通過(guò)findAll()查詢(xún)出多條數(shù)據(jù)。如何使其他數(shù)據(jù)庫(kù)內(nèi)的數(shù)據(jù)逐條加入該二維數(shù)據(jù)顯示?

你可以循環(huán)$userList,然后在循環(huán)里面分別查詢(xún)每個(gè)用戶的salary。但是其實(shí)可以一步實(shí)現(xiàn)的,只要改變一下sql。

為臨汾等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及臨汾網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、成都網(wǎng)站建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、臨汾網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

代碼:

$model = M();

$sql = "select user.*,salary.* from user,salary where salary.user_id=user.id and salary.time='2012-03-01' limit 0,10";

代碼供參考,你可以指定需要選取的字段和where條件。

PHP 讀取多條數(shù)據(jù)庫(kù)中數(shù)據(jù)

拿下面這段單獨(dú)建個(gè)頁(yè)面,改一下你的數(shù)據(jù)庫(kù)名,表等信息試試。

table width="50%" border="0"

tr

tdID/td

tdID2/td

tdorder1/td

tdorder2/td

tdorder3/td

/tr

?php

//連接數(shù)據(jù)庫(kù)

$conn=@ mysql_connect("服務(wù)器地址","用戶名","密碼") or die("連接數(shù)據(jù)庫(kù)失敗!");

mysql_select_db("數(shù)據(jù)庫(kù)名",$conn) or die("連接數(shù)據(jù)庫(kù)失敗!");

mysql_query("set names 'GBK'");

//連接結(jié)束

//接收提交過(guò)來(lái)查詢(xún)的ID

$id=$_POST["id"];

//查詢(xún)數(shù)據(jù)庫(kù)相關(guān)數(shù)據(jù)

$sql="select * from 數(shù)據(jù)表名 where ID2='".$id."' order by id desc";

$query=mysql_query($sql);

//循環(huán)輸出

while($row=mysql_fetch_array($query)){

?

tr

td?php echo $row["ID"];?/td

td?php echo $row["ID2"];?/td

td?php echo $row["order1"];?/td

td?php echo $row["order2"];?/td

td?php echo $row["order3"];?/td

/tr

?php

}

?

/table

form name="form1" method="post" action=""

input type="text" name="id"

input type="submit" name="Submit" value="查詢(xún)"

/form

php中怎樣讀取數(shù)據(jù)庫(kù)里的多條信息

$con = mysql_connect("localhost","root","");//連接數(shù)據(jù)庫(kù)

mysql_select_db("btxiazai",$con);//選擇數(shù)據(jù)庫(kù)

mysql_query("set names utf8");

$sql = "select * from persons order by id desc limit 2";//獲取persons中的數(shù)據(jù),并按id倒敘排列,取其中兩條

$get = mysql_query($sql);//執(zhí)行sql

while($result = mysql_fetch_assoc($get)){//取回?cái)?shù)據(jù)

}

php多次查詢(xún)mysql

##################################

/*

PHP 一次查詢(xún)數(shù)據(jù)庫(kù),多次使用。

作者:QQ 46429691

搜集齊()定位于搜索服務(wù),致力于下一代互聯(lián)網(wǎng)發(fā)展,通過(guò)先進(jìn)的搜索技術(shù)為網(wǎng)友提供更優(yōu)秀的互聯(lián)網(wǎng)服務(wù),目前為中國(guó)第五大搜索引擎。旗下?lián)碛芯W(wǎng)址、音樂(lè)、圖片、視頻、商機(jī)、人肉搜索等多個(gè)項(xiàng)目構(gòu)成搜集齊矩陣并由擁有多年大型網(wǎng)站運(yùn)營(yíng)經(jīng)驗(yàn)的(Yoo Lee)先生出任CTO。

*/

###################################

$qrystr = mysql_query("select * FROM pic_sort");

//形成新的數(shù)組,以后查詢(xún)就不經(jīng)過(guò)數(shù)據(jù)庫(kù)了直接訪問(wèn)$row1

while ($row = mysql_fetch_array($qrystr)) {

$row1[]=$row;

}

//比如取從0開(kāi)始的10條數(shù)據(jù)

$qrystr1="0,10";//這里這樣定義

$array=explode(",",$qrystr1);

for($i=$array[0];$i$array[1]+$array[0];$i++)

{

echo $row1[$i]["name"];//name為*里的任意字段名

}

標(biāo)題名稱(chēng):php查找多條數(shù)據(jù)庫(kù) php篩選查詢(xún)數(shù)據(jù)庫(kù)
網(wǎng)站網(wǎng)址:http://muchs.cn/article26/ddijecg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站靜態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站營(yíng)銷(xiāo)、外貿(mào)建站、定制開(kāi)發(fā)

廣告

聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)