我想在显示页码的底部添加三个类,我在PHP中使用它但是我无法弄清楚将php中的类名放在哪里以便工作...因为我得到了错误...
class="box_one" for ... << Prev Page
class="box_two" for ... echo $thenumrows or $i
class= "box_three" ... Next Page >>
这是代码......
<?php
if ($thenumrows != "")
{
echo "<br>";
if ($thecurrentpage > 1)
echo "<a href='". $_SERVER['PHP_SELF'] . "?cat= ". $theselectedcat ."&rows= "
. $thenumrows ."&page=". $thepreviouspage ."'>
<< Prev Page </a> "; for ($i=1;$i<=$totalpages;$i++)
{
if ($i == $thecurrentpage)
echo $i ." ";
else
echo "<a href='". $_SERVER['PHP_SELF'] ."?cat=". $theselectedcat ."&rows=".
$thenumrows ."&page=". $i ."'>$i</a> ";
}
if ($thecurrentpage < $totalpages)
echo "<a href='". $_SERVER['PHP_SELF'] ."?cat=". $theselectedcat ."&rows=".
$thenumrows ."&page=". $thenextpage ."'>Next Page >></a> ";
}
?>
请帮助谢谢。
AM
答案 0 :(得分:0)
我不得不清理你的代码。这些类将添加到a
- 标记:
if ($thenumrows != "") {
echo "<br />";
// Back
if ($thecurrentpage > 1) {
echo '<a class="box_one" href="'. $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $thepreviouspage . '"><< Prev Page</a> ';
}
// Paginating
for ($i=1; $i<=$totalpages; $i++) {
if ($i == $thecurrentpage) {
echo '<span class="box_two">' . $i .'</span> ';
}
else {
echo '<a class="box_two" href="' . $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $i . '">' . $i . '</a> ';
}
}
// Next
if ($thecurrentpage < $totalpages) {
echo '<a class="box_three" href="' . $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $thenextpage .'">Next Page >></a> ';
}
}
?>