#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    56
    Rep Power
    15
    I built a Forum with PHP4 and mySQL and is running pretty well. But a little question. How do I have it show 30 topics (something like that) at on every page and have the links to the other pages?

    Thanks in advance.

    --Ben.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    14
    Hi

    you'll need to add some paging to your code

    to give you the basic idea: (it'll be buggy mind =)

    <?
    $pagelength = 10;

    if (!$limit) {
    $limit = 0;
    }

    $sql = "select * from table LIMIT $limit,$pagelength";

    $res = mysql_result($sql);
    if ($res) $num = mysql_num_rows($res);

    if ($num) {
    while ($loop = mysql_fetch_array($res)) {
    print $some_stuff;
    }

    if ($num > $pagelength) {
    $limit = $limit + pagelength;
    print "<a href=mypage.php?limit=$limit">Next $pagelength</a>";
    }
    } else {
    print "No matches";
    }

    ?>

    "Back" will follow the same principles, but in reverse

    As I mentioned, this will break.
    For instance, you need to factor in the fact that ther might only be - say - 14 results.

    It gets sexy when you want to do
    << [1] [2] [3] [4] etc....

    hth

    Bealers

    ------------------
    http://back-end.org

    [This message has been edited by Bealers (edited August 07, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    14
    That code is shot to peices, however it'll hopefully give you an idea!?

    Bealers

    ------------------
    http://back-end.org
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    33
    Rep Power
    14
    $sql = "select * from table LIMIT $limit,$pagelength";

    $pagelength limits what in above statement.


  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Sweden
    Posts
    32
    Rep Power
    14
    To get mine to work, I used a sample that can be found at www.phpbuilder.com

    It's nice, if you need to use the "&" in your URL then simply add: global offset;
    and use a URL like this www.host.com/page.php3?id=123&offset=20

    That worked for me
    I didn't use it for a board but you could probably get it working with some modification.

    Toby

Similar Threads

  1. adjusting time duration from a drop down menu
    By spyghost in forum HTML Programming
    Replies: 9
    Last Post: March 1st, 2004, 02:05 AM
  2. time in - time out
    By newbiex in forum PHP Development
    Replies: 2
    Last Post: February 9th, 2004, 02:04 AM
  3. Replies: 8
    Last Post: February 8th, 2004, 12:04 AM
  4. how to develop/implement a discussion forum like this?
    By shm6417 in forum PHP Development
    Replies: 3
    Last Post: February 6th, 2004, 10:25 PM
  5. Adding minutes to time and other calcs
    By Jez433 in forum PHP Development
    Replies: 5
    Last Post: January 21st, 2004, 06:00 PM

IMN logo majestic logo threadwatch logo seochat tools logo