Alright, I have ventured out and attempted to write this code 100% myself. The problem is everything was working just fine until I tried to implement a reply system. This code would probably make a real PHP developer disgusted, I know there is probably an easier/more logical way to do this but from my knowledge this is the only way I know how to go about doing this.
What is your feedback?
<?php
//Get Comments From Database
$comments = mysql_query("SELECT id,user,comment,avatar FROM comments WHERE commentpage='$youtubeid' ") or die(mysql_error());
if (!$comments) { //Retrieve Comments
exit;
}else{
while ($commentrow = mysql_fetch_row($comments)){
$comment_id = $commentrow['0']; //Get Comment ID
$comment_user = $commentrow['1']; //Get Comment Author
$comment_message= $commentrow['2']; //Get Comment Message
$comment_avatar = $commentrow['3']; //Get Comment Avatar
$replies = mysql_query("SELECT user,comment,avatar FROM comments WHERE reply='$comment_id' ") or die(mysql_error());
if (!$replies) { //Retrieve Reply Comments
exit;
}else{
while ($commentreplyrow = mysql_fetch_row($replies)){
$comment_replyuser = $commentreplyrow ['0']; //Get Reply Comment Author
$comment_replymessage= $commentreplyrow ['1']; //Get Reply Comment Message
$comment_replyavatar = $commentreplyrow ['2']; //Get Reply Comment Avatar
echo $comment_user.'<br>'; //This is just for testing. I will make this look pretty after I get further in development.
echo $comment_message .'<br><br>';
echo $comment_replyuser.'<br>';
echo $comment_replymessage.'<br>';
}
}
}
}
?>