Yesterday I wrote up some javascript/php to retrieve info from a table named 'users' in a MySQL database. It takes the username and their 'wealth' and ranks them on score. But, the code below shows nothing except the headers. What's wrong with it? Thanks.
<div id="board">
<table border="1" cellspacing="0" cellpadding="2" width="620"><tbody>
<thead>
<tr>
<td>Username</td>
<td>Clicks</td>
</tr>
</thead>
<tbody>
<?php
$con = mysqli_connect('localhost','xxxx','xxxx','xxxx');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
} else {
mysql_select_db("users");
$results = mysql_query("SELECT username, wealth FROM users ORDER BY wealth DESC LIMIT 10");
while($row = mysql_fetch_array($results)) {
$username = $row['username'];
$wealth = $row['wealth']; }
}
?>
<tr>
<td><?php echo $username;?></td>
<td><?php echo $wealth;?></td>
</tr>
<?php
mysqli_close($con);
?>
</tbody>
</table>