$query = "SELECT * FROM `comments` WHERE `to` in (SELECT email FROM users WHERE email = '$email') ORDER by post_date ASC"; $result=mysql_query($query) or die(mysql_error()); $num=mysql_numrows($result); $i=0; while ($i < $num) { $from = htmlentities(mysql_result($result,$i,"from")); $comment = htmlentities(mysql_result($result,$i,"comment")); $post_date = htmlentities(mysql_result($result,$i,"post_date")); ?>