I use this function to display a list of users on an online RPG into a table, including a few other things such as their location and level.
function whosonline ()
{
$page = "Who is Online ";
$page .= "Whatever";
$onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-1200)."' ORDER BY charname", "users");
$page .= "<th colspan='4' style='background-color:#dddddd;'>";
$page .= "<center>Who is Online</center></th>";
$page .= " <th colspan='4' style='background-color:#dddddd;'>";
$page .= "There are " . mysql_num_rows($onlinequery) . " user(s) online within the last 10 minutes: </th> ";
$page .= " <th width=\"25%\" style=\"background-color:#dddddd;\">Name</th>";
$page .= "<th width=\"25%\" style=\"background-color:#dddddd;\">Class</th>";
$page .= "<th width=\"25%\" style=\"background-color:#dddddd;\">Last Seen</th>";
$page .= "<th width=\"25%\" style=\"background-color:#dddddd;\">Level</th> \n";
$count = 1;
while ($onlinerow = mysql_fetch_array($onlinequery)) {
if ($count == 1) { $color = "bgcolor='#ffffff' "; $count = 2; }
else { $color = "bgcolor='#eeeeee' "; $count = 1; }
$page .= " <tr><td width='25%'>";
$page .= $onlinerow["charname"]." </td>";
$page .= " <td width='25%'>".$onlinerow["username"]." </td>";
$page .= " <td width='25%'>".$onlinerow["currentaction"]." </td>";
$page .= " <td width='25%'>".$onlinerow["level"]." </td></tr>";
}
$page .= "</table> ";
$page .= "Whatever</center>";
display($page, "Who is Online");
}
The problem is, it doesnt show properly, the table is all over the page and out of place. it lists all the users, but thats about it. the rest of the page is up and down, and not in the correct places.
Can someone give me any guidance please?
thanks