Results 1 to 3 of 3

Thread: PHP paging

  1. #1
    Join Date
    Jun 2007
    Posts
    72
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default PHP paging

    Hi all, I have set up a charity website for a person I know (http://www.supportingourtroops.co.uk). It is all working fine, but there is one thing that I cannot work out, PHP paging I have had a look on google and here on the forum but still cant make any sense of it. The backend of the shop stores all the sales records, and the list is growing so I was going to try and add a paging system but cant work out how to do it, here is part of the code that makes the table:

    PHP Code:
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    ?>

    <link href="../../res/css/style.css" rel="stylesheet" type="text/css">

    <p>Here are the records for the shop:</p>

    <form name="form1" method="post" action="">
    <table width="80%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#494949" bgcolor="#EBF7FF" class="text">
      <tr>
        <td class="text">ID</td>
        <td class="text">IP</td>
        <td class="text">Name</td>
        <td class="text">Email</td>
        <td class="text">No. of Bands</td>
        <td class="text">Address</td>
        <td class="text">Cost</td>
        <td class="text">Payment Complete</td>
        <td class="text">Order Number</td>
        <td class="text">Date</td>
        <td class="text">Update</td>
        <td class="text">Delete</td>
        

    <?php 
    while($rows=mysql_fetch_array($result)){
    ?>
      </tr>
      <tr>
        <td><? echo $rows['id']; ?></td>
        <td><? echo $rows['ip']; ?></td>
        <td><? echo $rows['name']; ?></td>
        <td><? echo $rows['email']; ?></td>
        <td><? echo $rows['product']; ?></td>
        <td><? echo $rows['address']; ?></td>
        <td><? echo $rows['cost']; ?></td>
        <td><? echo $rows['payment']; ?></td>
        <td><? echo $rows['timestamp']; ?></td>
        <td><? echo $rows['dateadded']; ?></td>
       <td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">Update</a></td>
       <td align="center"><a href="delete.php?id=<? echo $rows['id']; ?>">Delete</a></td>

        <?
    }
    mysql_close();
    ?>
    </tr>
    </table>
    I would be very greatful if anyone can give me some clues about how to add paging to this. Thanks in advance for any help

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Just to give you a cheap answer try looking at the virtual pagination script. There is some nice code on that page for you to study or just cut and paste.

  3. #3
    Join Date
    Jun 2007
    Posts
    72
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default

    Thanks for the link, but I have finally managed to get a proper PHP one working.

Bookmarks

Posting Permissions

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