【发布时间】:2011-07-19 11:40:02
【问题描述】:
这段代码几乎只是显示了一个包含 16 个单元格(4 列和 4 行)的表格。除了右上角,还有两个“保留”单元格。这段代码也分页。
我想用这段代码修复两件事。现在两个“保留单元格”是相同的。意思是两个单元格都说保留。我如何做到这一点,以便我可以更改两个保留单元格内的内容。抱歉,如果这有点难以理解。
另外,我希望两个保留单元格仅显示在第一页上。除了第一页,它只会回显一个包含 4x4 单元格的表格,就好像保留的单元格不存在一样。
谁能让这成为可能?
废话不多说,代码如下:
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by GalleryID ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
$cell = 0;
echo '<table border="1" cellpadding="2" cellspacing="1"><tr>';
while($objResult = mysql_fetch_array($objQuery))
{
if($cell % 4 == 0) {
echo '</tr><tr>';
}
if($cell == 2 || $cell == 3) {
echo '<td>RESERVED</td>'; **//How do I make it so there are two separate reserve slots,
rather than one <td> which controls both cells?**
} else {
echo '<td><img src="https://s3.amazonaws.com/thumbnails/' . $objResult["Picture"] . '" />' .
$objResult["GalleryName"] . '</td>'; }
$cell++;
}
echo '</tr></table>';
?>
<br>
view more:
<?php
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>prev</a> ";
}
{
echo "|";
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>next</a> ";
}
?>
</body>
</html>
<?php
mysql_close($objConnect);
?>
【问题讨论】:
-
但这不是转发。这是一个有新问题的更新版本。
标签: php mysql pagination html-table cell