doumo6356 2014-04-02 16:48
浏览 26
已采纳

放置类或样式名称的位置

I want to add three class for bottom of pagination where show page number , I used that in PHP but I can't figure out where to put class name inside of php echo to make work... because i'm getting errors...

class="box_one" for ... << Prev Page             

class="box_two" for ... echo $thenumrows or $i

class= "box_three"  ... Next Page >>

here is code...

 <?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;";
         }
         ?>

please help thanks.

AM

  • 写回答

1条回答 默认 最新

  • duanhuanyou6478 2014-04-02 16:51
    关注

    I had to clean up your code. The classes are added to the a-tags:

    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;';
        }
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)