0

I have been searching for days and i can't find what is wrong with this.

I am trying to get the top users with the highest aproved number from the ranks table

SELECT * FROM ranks ORDER BY  cast(Aprovados  as unsigned) DESC LIMIT 10

This query works on the phpmyadmin page, i get the result that i am looking for

I am trying this in php like this

$result = mysqli_query($con,"SELECT * FROM ranks ORDER BY cast(Aprovados  as unsigned) DESC LIMIT 10"); 
             while ($row = mysql_fetch_assoc($result)) {
              echo $row['Nome'];
             }

I get no result's

When i run this

if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;}

I get no rows found, i don't understand why, i think my query is ok because it works on the server the $con i think is also good i can use it to get single rows with no problems

I searched alot and this is the must common awnser How to select multiple rows from mysql with one query and use them in php

Community
  • 1
  • 1
Tiago Oliveira
  • 1,582
  • 1
  • 16
  • 31

0 Answers0