Jump to content
Larry Ullman's Book Forums

Retrieving Related Posts - Php & Mysql ?


Recommended Posts

What does this mean exactly "Indeed I want to retrieve 3 post titles related to the one is viewed at the end of the post." If you are retrieving related posts you will need to check to see if the current post has a parent_id which is equal to the post_id. You will need an extra column in your posts table parent_id to do this, you will also need the post_id column which is a primary key and set to auto increment.

Link to comment
Share on other sites

When you initially load the page with the original post, you need to do whatever is necessary to figure out what the topic of the original post is. This will depend a lot on your site logic and DB structure, so I can't really advise you much beyond that.

 

Anyway, once you know what the original post is about, then you need to make a query at the bottom of the page to get the relevant posts and put them up.

Link to comment
Share on other sites

Ghamdan, I think I already answered your question, but when you're first loading the post (i.e., running the PHP script to get the original post), you need to establish what the post is about (e.g., Windows 8), and then query the DB in the same script for related posts, and posted them below the original post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...