Reputation: 23
I am currently in the process of creating a blog script. The posts show fine on the homepage but I was wondering if there was any way to show an individual blog post in a file with an ID (post.php?id=1) for the post with the database ID (1) and so on. I have already made the alterations on the index to take each blog post to the page with the same ID and just need some clarification on how I would get the correct info from my database.
Upvotes: 0
Views: 138
Reputation: 483
Use the following query to get information from the database:
"SELECT * FROM blog_posts WHERE id = '" . $_GET['id'] . "' LIMIT 1"
then fetch the information and output it to the page.
Upvotes: 1