放置类或样式名称的位置

时间:2014-04-02 16:48:47

标签: php class styles echo

我想在显示页码的底部添加三个类,我在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>&nbsp;&nbsp; "; for ($i=1;$i<=$totalpages;$i++)
         {
         if ($i == $thecurrentpage)
         echo $i ."&nbsp;&nbsp;";
         else
         echo "<a href='". $_SERVER['PHP_SELF'] ."?cat=". $theselectedcat ."&rows=". 
         $thenumrows ."&page=". $i ."'>$i</a>&nbsp;&nbsp;";
         }
         if ($thecurrentpage < $totalpages)
         echo "<a href='". $_SERVER['PHP_SELF'] ."?cat=". $theselectedcat ."&rows=". 
         $thenumrows ."&page=". $thenextpage ."'>Next Page >></a>&nbsp;&nbsp;";
         }
         ?>

请帮助谢谢。

AM

1 个答案:

答案 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>&nbsp;&nbsp;'; 
    }

    // Paginating
    for ($i=1; $i<=$totalpages; $i++) {
        if ($i == $thecurrentpage) {
            echo '<span class="box_two">' . $i .'</span>&nbsp;&nbsp;';
        }
        else {
            echo '<a class="box_two" href="' . $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $i . '">' . $i . '</a>&nbsp;&nbsp;';
        }
    }

    // Next
    if ($thecurrentpage < $totalpages) {
        echo '<a class="box_three" href="' . $_SERVER['PHP_SELF'] . '?cat=' . $theselectedcat . '&rows=' . $thenumrows . '&page=' . $thenextpage .'">Next Page >></a>&nbsp;&nbsp;';
    }
}
?>