Jump to content


Photo

help with formatting generated html code


  • Please log in to reply
2 replies to this topic

#1 xfezz

xfezz
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 26 October 2006 - 03:55 AM

Right now this is how my pagination looks like:
Posted Image


I would like it to look like this:
Posted Image

having the first back next and last links on the right of the page numbers.  I would like to have these two groups of links in two separate div tags for easy styling with css.

here is my code

// Build First page Link if not on the first page
if ($page != 1) {
   echo "<a href=\"".$_SERVER['PHP_SELF']."?page=1\">FIRST </a> ";
}

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><< Back</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "[<b>"."$i"."</b>] ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next >></a>";
}

// Build last page link if not on last page
if ($page != $total_pages) {
   echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$total_pages\"> LAST</a> ";
}

how would I go about doing this?

#2 mb81

mb81
  • Members
  • PipPipPip
  • Advanced Member
  • 120 posts

Posted 26 October 2006 - 04:40 AM

Just change the order of the different items using copy and paste.

As far as the positioning of the elements, you would need to use some tables or some absolute positioning to position the numbers in the middle and the first, previous, next, last on the right.

#3 xfezz

xfezz
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 26 October 2006 - 08:06 AM

ok after many hours of messing around and trying different variations i got it to do what id like it to do. i had to wrap the if block with a div tag. i was trying to do it inside of the if statement. so its something like this

echo "<div class=\"page_numbers\">";
for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "[<b>"."$i"."</b>] ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i </a>";
    }
}
echo "</div>"."\n";


thanks for your help






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users