Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts

    pagination alignment

    Hello everyone,

    I recently add pagination limit the displays on a page, however, I'm trying to change the alignment ( I've tried td align , div align, p align) nothing seemed to change the location, or if it did it apearred there were breaks.
    you can view the script at
    www.ericschuppe.com/usercheckouts.php

    PHP Code:
    <link href="styles.css" rel="stylesheet" type="text/css">
    <?php


    include ('dbc.php'); // Connect to the data base.





    $max 10//amount of articles per page. change to what to want

    $p $_GET['p'];

    if(empty(
    $p))

    {

    $p 1;

    }

    $limits = ($p 1) * $max;

    //view the news article!

    if(isset($_GET['act']) && $_GET['act'] == "view")

    {

    $id $_GET['id'];

    $sql mysql_query("SELECT * FROM checkout WHERE id = '$id'");

    while(
    $r mysql_fetch_array($sql))

    {

    $full_name $r['full_name'];

    $user_idnum $r['user_idnum'];

    $date $r['date'];

    $book $r['book'];

    $returned $r['returned'];

    echo 
    "<div><p>$full_name</p><p>$user_idnum</p><p>$date</p></div>";

    }



    }else{



    //view all the news articles in rows

    $sql mysql_query("SELECT full_name,user_idnum,DATE_FORMAT(`date`, '%m/%d/%Y %I:%i %p'),book,returned FROM checkout LIMIT ".$limits.",$max") or die(mysql_error());

    //the total rows in the table

    $totalres mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM checkout"),0);

    //the total number of pages (calculated result), math stuff...

    $totalpages ceil($totalres $max);

    //the table

    echo '<table align="center" cellspacing="2" cellpadding="2"><tr><td align="left"><b>Name</b></td><td align="center"><b>ID</b></td><td align="center"><b>Date</b></td><td align="center"><b>Book</b></td><td align="center"><b>Returned</b></td></tr><tr>';

    while(
    $r mysql_fetch_array($sql))

    {
       while (
    $r mysql_fetch_array($sqlMYSQL_NUM)) {
             echo 
    "<tr><td align=\"left\">" .
             
    stripslashes($r[0]) . "</td>
             <td align=\"left\">$r[1]</td>
             <td align=\"left\">$r[2]</td>
             <td align=\"left\">$r[3]</td>
             <td align=\"left\">$r[4]</td><tr>\n"
    ;

      }

    }

    //close up the table

    echo "</tr></table>";

    for(
    $i 1$i <= $totalpages$i++){

    //this is the pagination link

    $counter "<a href='usercheckouts.php?p=$i'>$i</a>";
    echo 
    "<span class=\"csstables\">$counter</span>";

    }

    }



    ?>
    Thank you agian.

  • #2
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Well this is more a HTML/CSS problem despite its association with PHP but I'll do my best to help you out.

    Try taking this part:

    PHP Code:
    <?php

    for($i 1$i <= $totalpages$i++){

    //this is the pagination link

    $counter "<a href='usercheckouts.php?p=$i'>$i</a>";
    echo 
    "<span class=\"csstables\">$counter</span>";



    ?>
    And replace it with this (adding the two echos before an after):

    PHP Code:
    <?php

    echo( "<div style='text-align: center;'>" );

    for(
    $i 1$i <= $totalpages$i++){

    //this is the pagination link

    $counter "<a href='usercheckouts.php?p=$i'>$i</a>";
    echo 
    "<span class=\"csstables\">$counter</span>";

    }

    echo( 
    "</div>" );

    ?>
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  • #3
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Quote Originally Posted by ShaneC View Post
    Well this is more a HTML/CSS problem despite its association with PHP but I'll do my best to help you out.

    Try taking this part:

    PHP Code:
    <?php

    for($i 1$i <= $totalpages$i++){

    //this is the pagination link

    $counter "<a href='usercheckouts.php?p=$i'>$i</a>";
    echo 
    "<span class=\"csstables\">$counter</span>";



    ?>
    And replace it with this (adding the two echos before an after):

    PHP Code:
    <?php

    echo( "<div style='text-align: center;'>" );

    for(
    $i 1$i <= $totalpages$i++){

    //this is the pagination link

    $counter "<a href='usercheckouts.php?p=$i'>$i</a>";
    echo 
    "<span class=\"csstables\">$counter</span>";

    }

    echo( 
    "</div>" );

    ?>
    I don't think that would work...

    I think this would:

    PHP Code:
    <?php

    echo( "<center>" );

    for(
    $i 1$i <= $totalpages$i++){

    //this is the pagination link

    $counter "<a href='usercheckouts.php?p=$i'>$i</a>";
    echo 
    "<span class=\"csstables\">$counter</span>";

    }

    echo( 
    "</center>" );

    ?>
    BTW: That code can't be validated but it works

  • #4
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    660
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Pray tell, why wouldn't that work?

    A div has an automatic width of 100%. You are aligning the numbers in the middle of it. The <center> tag is essentially doing something similar, but it will A) Not validate B) Not be supported in some browsers/circumstances.

    Edit: I just used Firebug on your website to modify it using the changes I suggested. It worked exactly as I intended: http://i43.tinypic.com/64jgix.jpg
    Last edited by ShaneC; 03-29-2009 at 02:28 AM.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  • Users who have thanked ShaneC for this post:

    eschuppe (03-29-2009)

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    25
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks Shane C. your method worked perefect!

  • #6
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    humm....

    looks like I didn't learn HTML that good....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •