-2

I have here my code

$query=mysqli_query($dbcon,"select count(user_name) from `viewlist` where user_name='$_name'");

What I want to do is that it only shows columns with the username $_name but arrange it on the table descending through id (which is auto increment). I have tried ordered by id DESC but didn't work.

Sam M
  • 4,136
  • 4
  • 29
  • 42
T. Mothy
  • 11
  • 3
  • Possible duplicate of [Best practice question for MySQL: order by id or date?](https://stackoverflow.com/questions/2166752/best-practice-question-for-mysql-order-by-id-or-date) – Vikasdeep Singh May 28 '18 at 01:29
  • 6
    This question doesn't make sense. If you're using the `COUNT` aggregator, without a `GROUP BY`, you're only going to get one result. Why would you need to order one result? – fubar May 28 '18 at 01:36
  • Forget about the php for now. Instead, see https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query – Strawberry May 28 '18 at 07:02

1 Answers1

-2

maybe..

$query=mysqli_query($dbcon,"select tb.* from (select count(user_name) as total from `viewlist` group by user_name) as tb order by tb.total desc");