0
<?php

$top10 = $mysqli->query("SELECT * FROM entries ORDER BY Votes ASC");

if ($top10->num_rows > 0) {
    // output data of each row
    while($row = $top10->fetch_assoc()) {
        echo "<li>" . $row['name'] . " " . "Votes: " . $row['Votes'] . "</li>";
    }
} else {
    echo "0 results";
}
?>

Instead of returning each row from the db, this just returning itself starting with query("SELECT ...

fusion3k
  • 11,568
  • 4
  • 25
  • 47
Dylan
  • 13
  • 1
  • Where's your database connection? – Panda Apr 02 '16 at 15:36
  • $mysqli = new mysqli("localhost","root","", "contest"); – Dylan Apr 02 '16 at 15:39
  • It connects just fine on my other pages – Dylan Apr 02 '16 at 15:39
  • 2
    *"this just returning itself starting with query("SELECT..."* - I don't know what you mean by that. Do you mean it's showing as code? – Funk Forty Niner Apr 02 '16 at 15:55
  • Yes. @Fred-ii- On the page, it is literally returning "query("SELECT * FROM entries ORDER BY Votes ASC"); if ($top10->num_rows > 0) { // output data of each row while($row = $top10->fetch_assoc()) { echo "
  • " . $row['name'] . " " . "Votes: " . $row['Votes'] . "
  • "; } } else { echo "0 results"; } ?>" – Dylan Apr 02 '16 at 16:06
  • then this tells me you're running this as `file:///file.php` rather than `http://localhost/file.php` (or `.html`). – Funk Forty Niner Apr 02 '16 at 16:09
  • possible duplicate of [PHP code is not being executed I can see it on source code of page](http://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-i-can-see-it-on-source-code-of-page) – Funk Forty Niner Apr 02 '16 at 16:10
  • @Fred-ii- Its running on localhost. – Dylan Apr 02 '16 at 16:11
  • what're you running under, Wamp, mamp, Xampp, other? – Funk Forty Niner Apr 02 '16 at 16:12
  • 1
    well your system's not parsing the PHP directives. Also, is this a `.php` file or `.html`? – Funk Forty Niner Apr 02 '16 at 16:17
  • You do not need to use `ASC` in your query as it is always `ASC` – A J Apr 03 '16 at 07:05