2013-03-26 79 views
0

你好我有以下代码,它是从数据库中排序结果,我如何设置它,所以结果将显示在2个不同的列,一个用于template.channel_item.php和一个用于template.channel_item.php其中2列将彼此相邻?画廊的格式数据库列表

if(is_array($array)) { 
foreach($array as $row) { 
    include($basepath.'/templates/template.channel_item.php'); 
    include($basepath.'/templates/template.channel_item_title.php'); 
} 

回答

0
if(is_array($array)) { 
foreach($array as $row) { 

    echo '<div id="left">'; 
    include($basepath.'/templates/template.channel_item.php'); 
    echo '</div>'; 

    echo '<div id="right">'; 
    include($basepath.'/templates/template.channel_item_title.php'); 
    echo '</div>'; 
} 

CSS

#right { float:left; width: 400px;} 
#left { float:left; width: 400px;} 
+0

谢谢!工作非常好 – user981220 2013-03-26 03:03:20

0

没有必要使用循环

<div class="item-section" style="clear:both"> 
<div id="left-sidebar"> 
<?php include($basepath.'/templates/template.channel_item.php'); ?> 
</div> 

<div id="right-sidebar"> 
<?php include($basepath.'/templates/template.channel_item_title.php'); ?> 
</div> 
</div> 

CSS

#left-sidebar, #right-sidebar { float: left; width: 400px; }