Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 每件物品都有不同的花式边框_Php_Css - Fatal编程技术网

Php 每件物品都有不同的花式边框

Php 每件物品都有不同的花式边框,php,css,Php,Css,嗨,伙计们,我试着这样做,就像我有5帧(花式边框),我有项目列表。当项目加载时,每个项目加载不同的框架。完成5帧后,第6帧重复帧列表。在我的剧本下面 <?php $allgfts=mysql_query("select id,image_url from {$statement} order by id limit {$startpoint}, {$limit}"); while($gfts=mysql_fetch_array($allgfts)) { $id=$gfts['id'

嗨,伙计们,我试着这样做,就像我有5帧(花式边框),我有项目列表。当项目加载时,每个项目加载不同的框架。完成5帧后,第6帧重复帧列表。在我的剧本下面

<?php
$allgfts=mysql_query("select id,image_url from {$statement} order by id limit {$startpoint}, {$limit}");
while($gfts=mysql_fetch_array($allgfts))
{
    $id=$gfts['id'];
    $image=$gfts['image_url'];
?>
    <div id="pic-1">
        <div class="thumbnail-item">
            <?php echo '<a href="g_detail.php?id='.$id.'"><img src="images/'.$image.'" alt="" width="161" height="161" class="thumbnail g-size" /></a>'; ?>
            <span><?php echo '<a href="g_detail.php?id='.$id.'">Readmore</a>';?></span>
            <?php echo '<a class="gtbtn" href="g_buy.php?id='.$id.'">Get This</a>';?>

        </div>     
    </div>  
<?php
}
?>  

使用余数运算符(“%”)。我不知道您的表结构是什么样的,但我将假设您的产品ID按顺序加载,从1开始

在WHILE循环中,使用以下命令:

$remainder = $id % 5;
if($remainder == 1){
    //load my DIV with frame 1
}
else($remainder == 2){
    //load my DIV with frame 2
}
......
//$arr being the array
$x=1; //start counter
$list = '<ul>'; //using a list, because that's what it is
for($i=0;$i<count($arr);$i++) {
    $list.='<li class="thumbnail-item">';
        $thumb ='<a href="g_detail.php?id='.$arr[$i][id].'">';
        $thumb.='<img src="images/'.$arr[$i][image_url].'" alt="" class="thumbnail g-size" /></a>';
        $thumb.='<span><a href="g_detail.php?id='.$arr[$i][id].'>Readmore</a></span>';
        $thumb.='<a class="gtbtn" href="g_buy.php?id='.$arr[$i][id].'">Get This</a>';
    $list.=$thumb;
    $list.='</li>';

if($x%5 == 0)||($x==count($arr)) {
    $list.='</ul>';
    if($x<count($arr)) {
        $list.='<ul>';
    }
    }
    $x++;
}
echo $list;

我想你是在问如何回显图像列表,并每隔五项将该列表换行一行

给定一个表的结果数组(顺便说一句,考虑使用PDO),我将执行以下操作:

$remainder = $id % 5;
if($remainder == 1){
    //load my DIV with frame 1
}
else($remainder == 2){
    //load my DIV with frame 2
}
......
//$arr being the array
$x=1; //start counter
$list = '<ul>'; //using a list, because that's what it is
for($i=0;$i<count($arr);$i++) {
    $list.='<li class="thumbnail-item">';
        $thumb ='<a href="g_detail.php?id='.$arr[$i][id].'">';
        $thumb.='<img src="images/'.$arr[$i][image_url].'" alt="" class="thumbnail g-size" /></a>';
        $thumb.='<span><a href="g_detail.php?id='.$arr[$i][id].'>Readmore</a></span>';
        $thumb.='<a class="gtbtn" href="g_buy.php?id='.$arr[$i][id].'">Get This</a>';
    $list.=$thumb;
    $list.='</li>';

if($x%5 == 0)||($x==count($arr)) {
    $list.='</ul>';
    if($x<count($arr)) {
        $list.='<ul>';
    }
    }
    $x++;
}
echo $list;
/$arr是数组
$x=1//启动计数器
$list=“
    ”//使用列表,因为这就是它
    对于($i=0;$i),你的问题是什么?