Hello all I have a table
“comment” as follows
commentid cmt followupid category
1 hello 3 starting
2 hi how are you 4 starting
3 Hello Jhon 5 followup
4 Hi I am fine and you 6 followup
I want to echo the records such that When I echo Hello the next comment that will appear is Hello John, when I echo Hi how are you the next comment that will appear is Hi I am fine and you.
I have tried to
$myQuery = "SELECT * FROM comment where category = 'followup' AND followupid = commentid ";
but it is not working.
The query as specified will get the results where the followupid is equal to commentid, and you don’t have any of those in your example.
For it to work you need to explicitly specify the commentid you’re looking for:
SELECT * FROM comment where category = 'followup' AND followupid = 3in case of PHP, you get this from the current record you’re printing:
echo $row['cmt'];mysql_query("SELECT * FROM comment where category='followup' and followupid={$row['followupid']}");