php
  • pagination
  • 2013-07-30 106 views 0 likes 
    0

    有配有3×3 的布局做分页问题的3x3这是我while循环,尝试了几个分页,但过于复杂分页,在每个页面

    while($row = mysqli_fetch_array($result)){ 
        $id = $row['id']; 
        $name = $row['name']; 
        $picture = $row['picture']; 
    
        $rowPic = "<td><a href='dologinuser.php?id=$id'>"; 
        $rowPic .= "<img width='200px' height='133px' src='images/$picture' />"; 
        $rowPic .= "</a><br/>"; 
        $rowPic .= "<strong>$name</strong>"; 
    
        echo $rowPic; 
    
        $split++; 
        if ($split%3==0){ 
        echo '</tr><tr>'; 
    
    +1

    贴全代码 – Kalai

    +0

    我有分页不知道,一切都太复杂:/ – ben

    +0

    http://www.9lessons.info/2010/10/pagination-with-jquery-php-ajax-and。 HTML – ben

    回答

    0

    如何做这样的事情?我相信这样更具可读性。

    <?php 
    // Grouping the code into table-like array 
    $count = 0; 
    while($row = mysqli_fetch_array($result)) { 
        $table[$count/3][$count % 3] = $row; 
        $count++; 
    } 
    
    // Constructing HTML code 
    $html = "<table>"; 
    foreach($table as $row) { 
        $html .= "<tr>"; 
        foreach($row as $col) { 
         $id = $col['id']; 
         $html .= "<td>" . "whatever you want to put" . "</td>"; 
        } 
        $html .= "</tr>"; 
    } 
    $html .= "</table>"; 
    ?> 
    
    相关问题