dspym82000 2014-12-19 06:20 采纳率: 100%
浏览 22

限制查询结果

This is my code..

<table>
                    <tr>
                        <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th>
                        <th>Thu</th><th>Fri</th><th>Sat</th>
                    </tr>

                    <tr>

                    <?php
    require("conn.php");
    $query = "SELECT * FROM temp WHERE id != (SELECT MAX(id) FROM temp)";
    $result = mysqli_query($con,$query);


    while($line = mysqli_fetch_array($result))
    {

     echo "<td>$line[4]<table><tr><td> $line[1]</td><td> $line[2]</td></tr></table></td>";


                    }
                    ?>

                    </tr>


                </table>

Now I am displaying only 7 records for only one week. I want to display first 7 records in first row and second 7 record in second row and so on..So how do I do that in my code. I am making changes but chages design and I dont want to change the design.

With above code result is like following .. enter image description here

I want to display only 7 records up to saturday and next 7 records in next row..

  • 写回答

1条回答 默认 最新

  • douxi8119 2014-12-19 06:31
    关注
    <table>
                        <tr>
                            <th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th>
                            <th>Thu</th><th>Fri</th><th>Sat</th>
                        </tr>
    
                        <tr>
    
                        <?php
        require("conn.php");
        $query = "SELECT * FROM temp WHERE id != (SELECT MAX(id) FROM temp)";
        $result = mysqli_query($con,$query);
        $i=1;
    
        while($line = mysqli_fetch_array($result))
        {
           echo "<tr>";
             if($i<=7){
                      echo  "<td>$line[$i]</td>";
                      $i++;   
                       }
               echo "</tr>;
         }
    
               //condition for next week 
                    $i=0;
         ?>      
        </tr>
                    </table>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?