SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Each page i have is in a different record in the database and i would like to know how to automatically at a previous and next page links with a description of the *next* page as the link??

  2. #2
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I presume that you've added ID columns in the database (ranging from 1 to infinity and auto_increment). If you've that, you must keep the ID of the current article in a variable available. For the 'back' button/link you simply decrease the ID by 1 and for the next button you increase it by 1.

    Then somewhere on the page you echo() the links to the script that you use to grab the articles out of db. It should look something like this:

    <a href=\"view-page.php?page=" . $back . "\">back</a>

    and:

    <a href=\"view-page.php?page=" . $next . "\">next</a>

    //echo() the description of the next page somewhere on the
    //page, like below the URL (I assume you've a description
    //ready in the db)

    Good luck
    <Edited by Elledan on 01-04-2001 at 10:20 AM>
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have fields called: PID and AID

    AID = article id

    PID = pid

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Elledan what happens when you delete a record wioth say ID number 3 and you alread yhave 50 records. That doesn't get reassigned so if your next link looked for 3 it wouldn't find it I think you would be better off to use those numbers that you pass as offsets with a limit of one in your query

    like mysql_query("SELECT * from table LIMIT $next, 1");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how would i go about this.

    AID stays constant for whole article while PID changes.
    What would i put on my page. Just for previous and next links. Making sure there is no previous link on the first page and a next on the last page?

    URL's look like this:

    http://www.codingclick.com/article.php?aid=1&pid=1


  6. #6
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, i couldn't find this in the forums before, but if i wanted a print template and had to join all of the pid's together to form one big article. How would i do this, and make sure they are in order?


    Sorry for any inconvenience caused

  7. #7
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess its kindof late .. hehe.. but i just finished writing a code snippet on the subject of creating next / prev links .. which would work with the form you have the database setup right now ...

    url as follows:
    http://www.geekarea.org/articles.php?action=show&id=12
    cogito, ergo sum

  8. #8
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Elledan
    I ... ranging from 1 to infinity and auto_increment ...
    Should I use as 32 bit or 64 bit integer to store infinity


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
  •