dqpdb82600 2014-01-14 16:45
浏览 6

在<tr>中划分时,第4个Mysql行丢失(每个表每行3个)

4th Mysql Row to be displayed is missing when dividing the result rows in <tr> elements, 3 items per row (3 per table-row 1 per colum)

This is an example of what I get:

Data #1 - Data #2 - Data #3
Data *#5* - Data #6 - Data #7

I've tried some topics from here but I couldn't achieve anything good :(

My code is:

<table class="table" cellpadding="5px" cellspacing="5px"> 
    <?php 
    $query_sql = mysql_query("SELECT * FROM table WHERE id='$id'");
    $counter = 0;
    while($row_row = mysql_fetch_assoc($query_sql)) {
        if ($counter++ % 3 == 0) {
           if ($counter > 0) {
               $output .= '</tr>';
           }
           $output .= '<tr>';
       }
       echo '<div class="col-md-4" style="border: #000 solid 1px;">                        
                  <div class="row" style="background-color: '.$row_c_border.';">
                    <div class="col-md-12">
                        <h4 class="text-white"><i class="icon-beaker" title="'.$row_course_degree['1'].'"></i>&nbsp;&nbsp;'.$row_row['place'].'&nbsp;'.$row_certified.'</h4>                    
                   </div>
                 </div>
                 <div class="row" style="background-color: #F5F5F5;">
                    <h6>&nbsp;&nbsp;&nbsp;<i class="icon-chevron-sign-right text-success" title="Began"></i>&nbsp;2009-01-11&nbsp;&nbsp;&nbsp;<i class="icon-flag text-info" title="Ended"></i>&nbsp;2015-01-11</h6>
                 </div>                           
                <div class="row">                                                 
                    <div class="col-md-2">                                           
                         <div style="height: 7px;"></div>
                         <img width="60px" height="62.5px" style="border: #F5F5F5 solid 1px;" src="'.$row_row['logo'].'" title="Establishment">       
                    </div>  
                    <div class="col-md-6" style="border-left: #F5F5F5 solid 1px"> 
                                &nbsp;
                    </div>
                 </div>
                 <div class="row" style="background-color: #F8F8FF;">
                    <div class="col-md-12">
                        <h6><i class="icon-info-sign"></i>&nbsp;&nbsp;'.$row_row['description'].'</h6>                
                   </div>
                 </div>
                </div>';
    }
    if ($counter > 0) {
        $output .= '</tr>';
    }

    ?>

</table>
  • 写回答

1条回答 默认 最新

  • douwang9650 2014-01-14 16:51
    关注

    A couple of problems stand out.

    Firstly

    if ($counter++ % 3 == 0) {
           if ($counter > 0) {
    

    the second test will always be true as the $counter is incremented on the previous line.

    Secondly, You are not outputting <td> tags for the table cells.

    either one of these problems will produce invalid html which could be the cause of your display issues.

    评论

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像