Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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 带fetch数组的Bootstrap 3列_Php_Arrays_Twitter Bootstrap - Fatal编程技术网

Php 带fetch数组的Bootstrap 3列

Php 带fetch数组的Bootstrap 3列,php,arrays,twitter-bootstrap,Php,Arrays,Twitter Bootstrap,我把网站设置为有3列,图片下有标题,标题下有描述x3。 如果我使用php输入单词,所有的显示都很好,但是当我使用fetch数组时,它会将列打断,并将每个列放在不同的行上。我目前的代码是: <!-- /.row --> <? while($row = mysql_fetch_array($result)){ ?> <!-- Projects Row --> <div class="

我把网站设置为有3列,图片下有标题,标题下有描述x3。 如果我使用php输入单词,所有的显示都很好,但是当我使用fetch数组时,它会将列打断,并将每个列放在不同的行上。我目前的代码是:

        <!-- /.row -->

        <?
    while($row = mysql_fetch_array($result)){
?>

        <!-- Projects Row -->
        <div class="row">
            <div class="col-md-4 portfolio-item">
                <a href="#">
                    <img class="img-responsive" src="../assets/img/tienda/<? echo $row["images"];?>" alt="">
                </a>
                <h3>
                    <a href="#"><? echo $row["top"];?></a>
                </h3>
                <p><? echo $row["desc"];?></p>
                </div>
        </div>
        </div>
        <hr>
        <!-- /.row -->
        <? } ?>
试一试


这个答案将处理PHP返回3个以上结果的可能性,这将需要另一行1-3个结果。您必须在CSS中添加一个.clearfix来清除:这两个都可以安全地清除col-md-4中包含的浮点值……此外,确保浮点值不会传播也是一个很好的做法

    <?
        $inc = 0;  //This is your incrementor
        while($row = mysql_fetch_array($result)){
           if ($inc == 0) {
    ?>
                <div class="row">
    <?     
           }
    ?>

                     <div class="col-md-4 portfolio-item">
                         <a href="#">
                              <img class="img-responsive" src="../link/<? echo $row["images"];?>" alt="">
                         </a>
                         <h3>
                             <a href="#"><? echo $row["top"];?></a>
                         </h3>
                         <p><? echo $row["desc"];?></p>
                    </div>

<?
         if ($inc == 0} {
?>
                   <div class="clearfix"></div>  
            </div>
<?
         }
         $inc = ($inc == 2)? 0 : $inc++;  //Increment unless value = 2, then set to zero   
      } 
?>

        <hr>

一切都很好,但如果你有3个以上的结果会怎么样?你想清除列使用的浮动并开始一个新的行div.@bpeterson76,我可以怎么做呢?谢谢,但由于某种原因,当我添加代码时,页面是空白的,我发现了错误,如果$inc==0}我现在只在一列中显示我已经看到了你所做的事情,并且非常感谢你的帮助。非常感谢
    <?
        $inc = 0;  //This is your incrementor
        while($row = mysql_fetch_array($result)){
           if ($inc == 0) {
    ?>
                <div class="row">
    <?     
           }
    ?>

                     <div class="col-md-4 portfolio-item">
                         <a href="#">
                              <img class="img-responsive" src="../link/<? echo $row["images"];?>" alt="">
                         </a>
                         <h3>
                             <a href="#"><? echo $row["top"];?></a>
                         </h3>
                         <p><? echo $row["desc"];?></p>
                    </div>

<?
         if ($inc == 0} {
?>
                   <div class="clearfix"></div>  
            </div>
<?
         }
         $inc = ($inc == 2)? 0 : $inc++;  //Increment unless value = 2, then set to zero   
      } 
?>

        <hr>