2017-06-23 16 views
-2

テーブルのフッターにページ番号が表示される問題があります。ここに私のPHPコードテーブルページ番号の位置の問題

<tfoot> 
    <tr> 
     <th colspan="5">Page</th> 
      ?php 
      $sql = "SELECT COUNT(ID) AS total FROM Settings"; 
      $result = $conn->query($sql); 
      $row = $result->fetch_assoc(); 
      $total_pages = ceil($row["total"]/$results_per_page); // calculate total pages with results 
      for ($i=1; $i<=$total_pages; $i++) { // print links for all pages 
       echo "<th> <a href='example.php?page=".$i."'"; 
       if ($i==$page) echo " class='curPage' </th>"; 
       echo ">".$i."</a> </th>"; 
       }; 
      ?> 
    </tr> 
</tfoot> 

CSSです:

ここ
body { 
    font-size: 15px; 
    color: #343d44; 
    font-family: "segoe-ui", "open-sans", tahoma, arial; 
    padding: 0; 
    margin: 0; 
} 
table { 
    margin: auto; 
    font-family: "Lucida Sans Unicode", "Lucida Grande", "Segoe Ui"; 
    font-size: 12px; 
} 
h1 { 
    margin: 25px auto 0; 
    text-align: center; 
    text-transform: uppercase; 
    font-size: 17px; 
} 
table td { 
    transition: all .5s; 
} 
/* Table */ 
.data-table { 
    border-collapse: collapse; 
    font-size: 14px; 
    min-width: 537px; 
} 
.data-table th, 
.data-table td { 
    border: 1px solid #e1edff; 
    padding: 7px 4px; 
} 
.data-table caption { 
    margin: 7px; 
} 
/* Table Header */ 
.data-table thead th { 
    background-color: #508abb; 
    color: #FFFFFF; 
    border-color: #6ea1cc !important; 
    text-transform: uppercase; 
} 
/* Table Body */ 
.data-table tbody td { 
    color: #353535; 
} 
.data-table tbody td:first-child, 
.data-table tbody td:nth-child(4), 
.data-table tbody td:last-child { 
    text-align: right; 
} 
.data-table tbody tr:nth-child(odd) td { 
    background-color: #f4fbff; 
} 
.data-table tbody tr:hover td { 
    background-color: #ffffa2; 
    border-color: #ffff0f; 
} 
/* Table Footer */ 
.data-table tfoot th { 
    background-color: #e5f5ff; 
    text-align: right; 
} 
.data-table tfoot th:first-child { 
    text-align: left; 
} 
.data-table tbody td:empty{ 
    background-color: #ffcccc; 
} 

画像が what it s look:

どのようにこの権利を行うことがありますか?すべてのページ番号をテーブルフッターの最後に合わせるにはどうすればいいですか?

+0

解決策がありますか? –

答えて

1

forループからthタグを削除するだけです。そして、thタグ内にページ番号をエコーし​​て、nosの間にスペースを入れます。コードを下記のコードに置き換えてください。

これはあなたのケースで動作します。

<tfoot> 
     <tr> 
      <th colspan="5">Page</th> 
          <?php 
          $sql = "SELECT COUNT(ID) AS total FROM Settings"; 
          $result = $conn->query($sql); 
          $row = $result->fetch_assoc(); 
          $total_pages = ceil($row["total"]/$results_per_page); // calculate total pages with results 
          echo "<th>"; 
          for ($i=1; $i<=$total_pages; $i++) { // print links for all pages 
            echo " &nbsp; <a href='example.php?page=".$i."'"; 
           if ($i==$page) echo " class='curPage' </th>"; 
            echo ">".$i."</a> &nbsp;"; 
           }; 
           echo "</th>"; 
          ?> 
     </tr> 
    </tfoot>