I grab data from my server and want them to display like this:

And instead, this happens:

I use PHP for the values:
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
Player Name
</td>
<td >
PK Level
</td>
<td>
Kills
</td>
<td>
Experience
</td>
</tr>
<tr>
<td >
<?php
$result = mysql_query("SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
echo $row['Runecraftlvl'];
echo "<br />";
}
?>
</td>
<td>
<?php
$result = mysql_query("SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
echo $row['Runecraftlvl'];
echo "<br />";
}
?>
</td>
<td>
<?php
$result = mysql_query("SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
echo $row['Runecraftlvl'];
echo "<br />";
}
?>
</td>
<td>
<?php
$result = mysql_query("SELECT * FROM high ORDER BY Runecraftlvl DESC LIMIT 20");
while($row = mysql_fetch_array($result))
{
echo $row['Runecraftlvl'];
echo "<br />";
}
?>
</td>
</tr>
</table>
Why is this happening? How can I make the data go on separate rows, 4 data each row?
Before giving away any code, I’ll give you a few hints.
Since you’re not getting my point… You should add a counter yourself, and check whether or not you have to close the row.
But… Because you want 4 values in one cell, you will have to write them to temporary variables. You would need 4 variables: player_name, pk_level, kills and experience. When you’ve read out every 4th row of your query result, write them to the table.
($counter % 4) == 0will be the main if-clause in your code. This will betruewhenever the remainder of the division$counter / 4is 0.Also remember: you only need to perform your query once.
Give it a try first, and let us know what you come up with.