Search the Community
Showing results for tags 'top10'.
-
Hello, i'm trying to make a "top 10 voters" page, the only thing is, i'm quite new with the use of php in combination with sql. I've searched online a lot after i've figured out how to get, and store the username in the database, and if it already existed it adds 1 to "votes". Now i want to use that data to create a top 10 voters page. The only problem, i can't really find a tutorial for making a top 10. Maybe someone here could help me out with it? I've started writing the code a bit, but i got stuck between the query and fetching the data and looping it. The error i get: The full code as it is now: <? /* MYSQL connectie */ $conn = new Mysqli("localhost", "username", "password", "tylerwx94_cwvote") or die ('Error: ' . mysqli_errno($conn)); /* mysql selectie */ $results = mysqli_query($conn, "SELECT `players` FROM `tylerwx94_cwvote` ORDER BY `votes` DESC LIMIT 10") or die('Error: ' . mysqli_errno($results)); while ($row = mysqli_fetch_assoc($results)) { echo $row['players'] . "\n"; } ?> Any help with my code or link to a good tutorial would be appreciated! Sorry if it is in the wrong section, don't know if it belongs in mysql or php.