I want to make a live top 6 users
I want to extract from mysql highest value of each row, and their username.
<?php
include_once 'config.php';
$query = $config -> prepare("
SELECT `UserID`
, `Humanity`
, `Headshots`
, `Murders`
, `BanditsKilled`
, `ZombiesKilled`
, `pAliveTime`
FROM `users`
ORDER
BY `UserID` ASC
LIMIT 10
");
if($query -> execute())
{
$query_results = $query->fetchAll();
}
?>
then in html
<div class="colw_3 spec-l border-right">
<p></p><p><strong><em><font color="white">Humanity</font></em></strong><br>
</p>
<p><strong><em><font color="white">Headshots:</font></em></strong><br>
</p>
<p><strong><em><font color="white">Bandits Killed:</font></em></strong><br>
</p>
<p><strong><em><font color="white">Murders</font></em></strong><br>
</p>
<p><strong><em><font color="white">Zombies Killed</font></em></strong><br>
</p>
<p><em><strong><font color="white">Alive Time:</font></strong></em><br>
</p>
</div>
<!-- END col_6 -->
<div class="colw_3 paddbott100 spec-r">
<p></p><p><strong><font color="white"> <?php echo $query_result["Humanity"]; ?></font></strong><br>
</p>
<p><strong><font color="white"> <?php echo $query_result["Headshots"]; ?></font></strong><br>
</p>
<p><strong><font color="white"> <?php echo $query_result["BanditsKilled"]; ?></font></strong><br>
</p>
<p><strong><font color="white"> <?php echo $query_result["Murders"]; ?></font></strong><br>
</p>
<p><strong><font color="white"> <?php echo $query_result["ZombiesKilled"]; ?></font></strong><br>
</p>
<p><strong><font color="white"> <?php echo $query_result["pAliveTime"]; ?></font></strong><br>
</p>
</div>
but I don't know how should I write the query so I get the values and the username of those values
it should look like this
Humanity: 5000 - Username's value. (without 's value) Bandits Killed: 4 - Username's value (another username, or the same username, depends who has the highest value on BanditsKilled column)
Currently my code orders ascending by userID..
WHEREclause to your query to limit it to a specific user ID, or to loop over$query_resultswith aforeachloop. Also, please note that the<font>tag is not supported in HTML5. Use CSS for styling instead :)