php如何把图片分为一行显示3张就换行(从数据库读取)
<divclass="content">{phpx:$i=0;}<{--loopx$data$_usershow--}>{phpx:$username=$_usersho...
<div class="content">
{phpx: $i=0;}
<{--loopx $data $_usershow--}>
{phpx: $username=$_usershow['username'];}
{phpx: $row = $db->fetch_first("SELECT uid FROM cdb_members WHERE username='$username'");}
{phpx: $avatar = discuz_uc_avatar($row['uid'], 'small', false);}
<div class="usershow">
<dd class="avatar">
<a href="{$_usershow['themelink']}">{$avatar}</a>
</dd>
<dt class="au"><a href="{$_usershow['themelink']}">{$_usershow[username]}</a></dt>
</div>
<{--endloop--}>
</div>
模型页的数据操作如下:
include './include/usershow.cls.php';
$_usershow = new usershow($dbop, $db); //new一个类
$data = $_usershow->select('index'); //调用类中的方法
下面住了的是和在模版页循环打印的头像相同
/*foreach ($data as $_usershow){
$username=$_usershow['username'];
$link = $_usershow['themelink'];
$row = $db->fetch_first("SELECT uid FROM cdb_members WHERE username='$username'");
var_dump($row);
$avatar = discuz_uc_avatar($row['uid'], 'small', false); //false—直接打印头像
echo discuz_uc_avatar($row['uid'], 'small', true); //true—头像链接地址
echo ($avatar);
echo(' ');
echo ($username);
echo('<br/>');
}*/ 展开
{phpx: $i=0;}
<{--loopx $data $_usershow--}>
{phpx: $username=$_usershow['username'];}
{phpx: $row = $db->fetch_first("SELECT uid FROM cdb_members WHERE username='$username'");}
{phpx: $avatar = discuz_uc_avatar($row['uid'], 'small', false);}
<div class="usershow">
<dd class="avatar">
<a href="{$_usershow['themelink']}">{$avatar}</a>
</dd>
<dt class="au"><a href="{$_usershow['themelink']}">{$_usershow[username]}</a></dt>
</div>
<{--endloop--}>
</div>
模型页的数据操作如下:
include './include/usershow.cls.php';
$_usershow = new usershow($dbop, $db); //new一个类
$data = $_usershow->select('index'); //调用类中的方法
下面住了的是和在模版页循环打印的头像相同
/*foreach ($data as $_usershow){
$username=$_usershow['username'];
$link = $_usershow['themelink'];
$row = $db->fetch_first("SELECT uid FROM cdb_members WHERE username='$username'");
var_dump($row);
$avatar = discuz_uc_avatar($row['uid'], 'small', false); //false—直接打印头像
echo discuz_uc_avatar($row['uid'], 'small', true); //true—头像链接地址
echo ($avatar);
echo(' ');
echo ($username);
echo('<br/>');
}*/ 展开
展开全部
这个很简单,你应该是用foreach来循环的吧,那就foreach($arr as $p=>$list){
if($p%3==0){
echo $list['pic'].'<br>'; //只要是3的倍数就要在后面加一个换行就行了
}
}
if($p%3==0){
echo $list['pic'].'<br>'; //只要是3的倍数就要在后面加一个换行就行了
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
php如何把图片分为一行显示3张就换行(从数据库读取)
悬赏分:0 - 离问题结束还有 14 天 22 小时
<div class="content">
{phpx: $i=0;}
<{--loopx $data $_usershow--}>
{phpx: $username=$_usershow['username'];}
{phpx: $row = $db->fetch_first("SELECT uid FROM cdb_members WHERE username='$username'");}
{phpx: $avatar = discuz_uc_avatar($row['uid'], 'small', false);}
<div class="usershow">
<dd class="avatar">
<a href="{$_usershow['themelink']}">{$avatar}</a>
</dd>
<dt class="au"><a href="{$_usershow['themelink']}">{$_usershow[username]}</a></dt>
</div>
{
$i++;
if($i%3==0)
echo "<div style=\"clear:both;\"></div>";
}
<{--endloop--}>
</div>
前提<div class="usershow">这个层你要宽度高度都调好了,保证3个一行不超过上层容器的宽度并且float:left;
悬赏分:0 - 离问题结束还有 14 天 22 小时
<div class="content">
{phpx: $i=0;}
<{--loopx $data $_usershow--}>
{phpx: $username=$_usershow['username'];}
{phpx: $row = $db->fetch_first("SELECT uid FROM cdb_members WHERE username='$username'");}
{phpx: $avatar = discuz_uc_avatar($row['uid'], 'small', false);}
<div class="usershow">
<dd class="avatar">
<a href="{$_usershow['themelink']}">{$avatar}</a>
</dd>
<dt class="au"><a href="{$_usershow['themelink']}">{$_usershow[username]}</a></dt>
</div>
{
$i++;
if($i%3==0)
echo "<div style=\"clear:both;\"></div>";
}
<{--endloop--}>
</div>
前提<div class="usershow">这个层你要宽度高度都调好了,保证3个一行不超过上层容器的宽度并且float:left;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |