i have a table where same data is appearing again and again the table structure is like below.id is autoincrement.pm is for userid.it will appear again and again like beliw table.i want to display the output as the extract of entire table in descending order. suppose the table consists of 100 rows and the userid 15 comes 10 times which is highest then it should come at the top then the other id which is coming next like that . i tried but not working here is my code as well
id userid
1 33
2 34
3 37
4 33
5 33
6 37
the output i want is
userid nos
33 3
37 2
34 1
please guide . i tried with this code
$res = sql_query("select count(userid) as total from tableA");
echo'<table>';
while ($row = sql_fetch_array($res)) {
echo ' <tr><td>'.$row['userid'].'</td></tr></table>';
Then you can access:
$row['userid']for the user ID$row['nos']for the count