Answer the question
In order to leave comments, you need to log in
How to display a comment below the article under which it was written using PDO PHP?
Hello.
I have two tables:
articles(id, title, slug, content, author_id, date)
and comments(id, author_id, article_id, content, date)
. I want to display the comments below the post it's set under, i.e. compare if the id from the articles table matches the article_id from the comments table. This is a self-written blog, no templates or patterns, I use PDO PHP. I roughly do the following:$stmt = $db->query('SELECT * FROM articles');
$comments = $db->prepare('SELECT * FROM comments WHERE article_id = ?');
Answer the question
In order to leave comments, you need to log in
This may be terrible code, but I've only been familiar with this for a month, sorry.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question