Skip navigation
Currently Being Moderated

Displaying each result on its own page?

Apr 18, 2012 12:55 AM

I'm creating a blog based on a guestbook format.

 

Basically at the moment I have an 'Add Post' page, that stores the post details in a database and then when you go to the index page all of the posts, including author name etc. are dumped in order.

 

But I want it to be more like a blog, how do I go about displaying each individual entry on it's own page. So the posts are listed on the main page, you click the title and it brings you to a page displaying only that post?

 

And another question, how would I go about displaying five posts on the index page rather than all of them? And then being able to click an 'older posts' link to see the previous five posts?

 

Thanks.

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 3:53 AM   in reply to Abidubbah

    Hi,

     

    You create a new cfm page whose responsability is only to display the post...lets call it display.cfm.

    This page needs the ID of the post...an ID that is related to the database entry (can be you primary key in the table that you are storing the posts).

     

    All you have to do for this page to have the necessary info to display the post is pass a parameter in the URL (called query string)...something like this <base_url_here>\display.cfm?id=1

    You get this ID...select the post with this ID from the database and you are done.

     

    In your main page, you must create the link to this page dynamically as the id will change for every entry.

     

    So the display page is allways the same but the contents change according to the ID passed in the query string.

     

    Regarding the five post display....

     

    You can do it in the select to the database...or if you have an array of entries you display only the first 5

    Then you have a link...to the same page perhaps with a different query string that displays all of them....

     

    If you have any other doubts just ask.

     

    Regards.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points