Retrieving data from MySQL in particular order

Codes here !

Moderators: macek, egami, gesf

direct99
New php-forum User
New php-forum User
Posts: 2
Joined: Tue May 20, 2014 10:18 am

Retrieving data from MySQL in particular order

Postby direct99 » Tue May 20, 2014 10:30 am

I don't know how to ask this question but I'll try my best. I am designing a Comment and Reply system such that each comment has a particular number of replies and the comments and replay are stored separately in two tables in the same MySQl database, so we have to two tables

Table 1

Comment ID | Comment | Date

Table 2

X | Reply Text | Date

where X represents the comment's ID the reply belongs to.

I know that the code

$res=mysql_query("SELECT * from commenttable ORDER BY `Date` DESC ");
while($row=mysql_fetch_array($res))
{
echo $row["Comment"];
}


lists the comments from recent to old.

Is it possible to modify this code to list the comments from the one with biggest number of replies to least.

direct99
New php-forum User
New php-forum User
Posts: 2
Joined: Tue May 20, 2014 10:18 am

Re: Retrieving data from MySQL in particular order

Postby direct99 » Tue May 20, 2014 9:48 pm

Any Ideas?


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests

cron