I read an article and its comments from mysql database with two separate queries as
$result = mysql_query("SELECT * FROM articles WHERE article_id='$id'");
$row = mysql_fetch_array($result);
$title=$row['title'];
........
AND
$result = mysql_query("SELECT * FROM comments WHERE article_id='$id'");
while($row = mysql_fetch_array($result)) {
$comment_title=$row['title'];
.........
}
Is the best way to read this set of data from database? OR
Is it possible to catch the data through one query or one transaction?
NOTE: My issue is that first query for article is only for one row; but the second one needs a loop to process (and display in html) several comments.
1 Answer