0
First see the image of my database (the link arrows from one table to another are the inner join
's): http://prntscr.com/6wjl4h
Current query:
"SELECT
question.*,
questioncomments.*,
login.*
FROM questioncomments
INNER JOIN question
ON questioncomments.comment_question_ID = question.question_ID
INNER JOIN login
ON question.autor_id = login.user_ID
ORDER BY question.question_ID";
Part of my PHP code:
<?php
while($row = $result->fetch_assoc()) {
echo "<hr>[Row 'titulo'] TITLE: " . $row["titulo"] . "<br><br>QUESTION: " . $row["question"] . "<br><br>COMMENT: " . $row["comment"] . "<br><br>";
}
?>
Question:
How to have the comments included in each "question_id" instead of multiplying each question with each answer?
Expected result (before see the bad result):
TITLE: Please help me
QUESTION: What is GOOGLE?
COMMENT: is a Searcher
COMMENT: is a game
Bad result:
TITLE: Please help me
QUESTION: What is GOOGLE?
COMMENT: is a Searcher
TITLE: Please help me
QUESTION: What is GOOGLE?
COMMENT: is a game
vo try this , I have not gotten anything yet because of the errors of your code
– Kevin mtk
THANK YOU <3 YOU ARE A GENIUS!!!!!! 11
– Kevin mtk
Could you give me a translated summary of what this code does ? It worked perfectly, thank you
– Kevin mtk
I created a control variable $idControle that starts with 0. In the first iteration of while let’s assume that the question_ID is 1, the IF will check if (0 != 1), if it is it will print the issue header and then the first comment, then $idControle gets 1. In the next iteration it will only print the header of the question again if the question_ID is different from 1. ?
– Euler01