php如何調用兩個關聯資料表裡的資料

來源:互聯網
上載者:User
php怎麼調用兩個關聯資料表裡的資料
$query = $db->query("SELECT list_dir,list_id,list_name,list_status FROM ff_list WHERE list_status != 0 ORDER BY list_id ASC LIMIT 0, 30");
while($n = $db->fetch_array($query)) {


$query = $db->query("SELECT vod_name,vod_cid FROM ff_vod WHERE vod_cid in ($n['list_id']) ORDER BY rand() LIMIT 0, 10");
while($m = $db->fetch_array($query)) {

$z[]='

".$n['list_name'].$m['vod_name'].'

';
}
}


怎麼雙重while調用 ,或者用其它的調用方法調用達到我相要的效果
ff_list資料表是欄目列表
ff_vod是文章列表
兩表的關聯欄位是:vod_cid=list_id
就是吧ff_list裡的所有欄目名稱調用出來,然後在欄目名稱下面顯示10條文章,怎麼一次性調用出來,看好多論壇或CMS都可以


例如:
欄目名稱:軍事新聞
aaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbb
ccccccccccccccccc
ddddddddddddddddd
eeeeeeeeeeeeeeeee

欄目名稱:娛樂新聞
ffffffffffffffffff
gggggggggggggggggg
hhhhhhhhhhhhhhhhhh
...........


小弟是菜鳥,麻煩知道的大哥直接給代碼,謝謝了

分享到: 更多


------解決方案--------------------
$z[]='';

這樣不行嗎?
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.