我使用這個代碼來創建一個無限的表我的MySQL查詢:如何製作MySQL無限數組表?
<table cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
<!-- Table Header -->
<thead>
<tr>
<th>User</th>
<th>SteamID</th>
<th>Banned by</th>
<th>Admin SteamID</th>
<th>Time Banned (min)</th>
<th>Reason</th>
</tr>
</thead>
<!-- Table Header -->
<!-- Table Body -->
<tbody>
<?php
echo '<tr>';
for($i = 0; $bans = mysqli_fetch_array($query2); $i = ($i+1)%3){
echo '<td>'.$bans['name'].'</td>';
echo '<td>'.$bans['steamid'].'</td>';
echo '<td>'.$bans['nameAdmin'].'</td>';
echo '<td>'.$bans['steamidAdmin'].'</td>';
echo '<td>'.$bans['time'].'</td>';
echo '<td>'.$bans['reason'].'</td>';
if($i == 2)
echo '</tr><tr>';
}
echo '</tr>';
?>
</tbody>
我從Mysql fetch array, table results
它正常工作的代碼,但它不能正確去進一步下跌超過6行。其他行無論出於何種原因放置在我最後一列的右側,如此截圖所示: http://puu.sh/h0qZF/a12de1dd87.png
我該如何解決這個問題?我的代碼有問題嗎?爲什麼會發生?
',而(真)回聲「
你所說的‘無限表’?的意思是,當你說,一個無限循環在我心中觸發,爲什麼你會想要那個? – CodeGodie 2015-04-03 21:05:56
我只是表示該表的行將與我選擇的數據庫表中的行數相同。這是在這裏發現的概念:http://stackoverflow.com/questions/6757082/mysql-fetch-array-table-results – Aris 2015-04-03 21:07:52