php如何调用两个关联数据表里的数据

WBOY
Release: 2016-06-13 11:45:03
Original
1835 people have browsed it

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");<br />while($n = $db->fetch_array($query)) {<br /><br /><br />$query = $db->query("SELECT vod_name,vod_cid FROM ff_vod WHERE vod_cid in ($n['list_id']) ORDER BY rand() LIMIT 0, 10");<br />while($m = $db->fetch_array($query)) {<br /><br />        $z[]='<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].$m['vod_name'].'</a></h3></div>';<br />}<br />}
Copy after login


怎么双重while调用 ,或者用其它的调用方法调用达到我相要的效果
ff_list数据表是栏目列表
ff_vod是文章列表
两表的关联字段是:vod_cid=list_id
就是吧ff_list里的所有栏目名称调用出来,然后在栏目名称下面显示10条文章,怎么一次性调用出来,看好多论坛或CMS都可以


例如:
栏目名称:军事新闻
aaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbb
ccccccccccccccccc
ddddddddddddddddd
eeeeeeeeeeeeeeeee

栏目名称:娱乐新闻
ffffffffffffffffff
gggggggggggggggggg
hhhhhhhhhhhhhhhhhh
...........


小弟是菜鸟,麻烦知道的大哥直接给代码,谢谢了

';   

这样不行么?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template