简体   繁体   中英

PHP list top 10 highest vaules in MySQL table

I'm trying to list the top highest 10 values in my MySQL table.

I've tried this:

              $SQL = ("SELECT * Rating FROM download_manager ORDER BY Rating DESC LIMIT 10;");
              $results = mysqli_query($SQL);
              var_dump($results);

However that returns a NULL, also I'd need it to echo back two rows and not the whole table...

DB Structure: id | filename | downloads

I need to just echo back the top 10 highest downloads and the associated filename.

Update:

Rating is not the table, connection is done through a require connect. I've removed the () however still get a null.

Try that

$SQL = "SELECT Rating FROM download_manager ORDER BY Rating DESC LIMIT 10;";
              $results = mysqli_query($SQL);
              var_dump($results);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM