2 Replies Latest reply on Apr 18, 2012 11:25 AM by Abidubbah

    Displaying each result on its own page?


      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?



        • 1. Re: Displaying each result on its own page?



          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.



          • 2. Re: Displaying each result on its own page?
            Abidubbah Level 1

            It worked so well, thank you very much.