Hey all,

So here's the deal. I have a list of comments, and each comment gets an automatically generated commentid when it gets added to my mysql table. I just added the functionality to allow users to reply to other ppl's comments ... So I added another field to my table called replytoid. This field holds the commentid number of the comment being replied to.

When someone views a blog, I want it to display all the associated comments in ASC order. If a comment is actually a reply to another comment, it should show up directly under it (despite the commentid number).

I normally use ORDER by or Group by in my mysql queries to organize data for output. The pages are in php.

$cmtqry="select * from ".BLOG_COMMENTS." where eparent='".$HTTP_GET_VARS['blogid']."' order by commentid, replytoid";
                $cmtres=mysql_query($cmtqry);
                $cmtrows=mysql_num_rows($cmtres);
                if($cmtrows > 0){
                while($cmtarr=mysql_fetch_array($cmtres)){

But this doesn't seem to work correctly. I also used the conjunction of the group by and order by... that didn't work either.

Is there another way to do this?? Any help would be appreciated!

i did it using a variable in a loop

e.g

} Do
 
 
display $recordnum
 
$recordnum ++
 
{ Loop until recordnum = last in database
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.