Pregunta

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

¿Fue útil?

Solución

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;';
    }
}
?>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top