在我的页面上,我想对数据库进行查询并对结果进行分页,以便它们根据当前查看页面的人数按降序排列。我希望它从左到右读取前三名,然后换到新行,然后从左到右再次读取结果四到六,依此类推。
所以我的表格是这样布置的:
<div class="popular1">
<table class="pop-table-thumb">
<tr colspan="3">
<div class="pop-table-header">
Most popular
</div>
<br>
</tr>
<tr>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
</tr>
<tr>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
</tr>
<tr>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
<td>
<div class="pop-thumb">
<img class="img-thumb" src="Images/DefaultThumbnail.gif"/>
</div>
</td>
</tr>
</table>
</div>
我知道如何进行基本的分页并列出来自 assoc 查询的结果,例如:
$query = mysql_query("SELECT `something` FROM `something`");
while ($assoc_array = mysql_fetch_assoc($query)) {
echo '<p>', $assoc_array['something'] ,'</p>';
}
那么有人对我应该如何处理有任何想法吗?