Jump to content

help with formatting generated html code


xfezz

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?
Link to comment
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.
Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.