Jump to content

Archived

This topic is now archived and is closed to further replies.

xfezz

help with formatting generated html code

Recommended Posts

Right now this is how my pagination looks like:
[img]http://img.photobucket.com/albums/v487/xfezz/now.jpg[/img]


I would like it to look like this:
[img]http://img.photobucket.com/albums/v487/xfezz/would_like.jpg[/img]

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

[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> ";
}
[/code]

how would I go about doing this?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

[code]
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";

[/code]

thanks for your help

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.