21,887
社区成员
发帖
与我相关
我的任务
分享
$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[]='<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].$m['vod_name'].'</a></h3></div>';
}
}
select list_name,vod_name from ff_list,ff_vod
where vod_cid=list_id
and list_status != 0
and vod_cid in ($n['list_id']) ORDER BY rand() LIMIT 0, 10
select list_name,vod_name,ff_list,ff_vod
where vod_cid=list_id
and list_status != 0
and vod_cid in ($n['list_id']) ORDER BY rand() LIMIT 0, 10
$query1 = $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($query1)) {
$query2 = $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($query2)) {
$z[]='<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].$m['vod_name'].'</a></h3></div>';
}
}
$query1 = $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($query1)) {
$z[]='<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].'</a></h3>';
$query2 = $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($query2)) {
$z[]='<h3>'.$m['vod_name'].'</h3>';
}
$z = $z[].'</div>';
}
就是要在外层循环结尾处加个</div>,也就是在栏目30个循环后面加个</div>
得到的效果是:
'<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].'</a></h3>'.'<h3>'.$m['vod_name'].'</h3>'.'</div>';
'<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].'</a></h3>'.'<h3>'.$m['vod_name'].'</h3>'.'</div>';
如果这样加外层就把内层的隔断了:$z[]='<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$n['list_name'].'</a></h3>'.'</div>';
如果这样加到内层又每条文章都有个</div>:$z[]='<h3>'.$m['vod_name'].'</h3>'.'</div>';
像我红色部分这样又有错误
不知道问题说明白了吗?版主麻烦,谢谢了!$query1 = $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($query1)) {
$z[]='<div class="linkbox"><h3>'.$n['list_name'].'</h3></div>';
$query2 = $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($query2)) {
$z[]='<div class="linkbox"><h3><a href='."'/".$n['list_dir']."/'>".$m['vod_name'].'</a></h3></div>';
}
}