Jump to content

Need Help with Users Online


Ambuu

Recommended Posts

When users log on, they change the value of online from 0 to 1.

Here is the code to display the "online" table (it has 'ID', 'online', and 'user' fields)

 

$connection = mysql_connect($host, $user, $password);
$db = mysql_select_db($database, $connection);


if (!mysql_connect($host, $user, $password))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");


$result = mysql_query("SELECT * FROM online");
if (!$result) {
die("Query to show fields from table failed");
}
$online = mysql_fetch_assoc($result);

$fields_num = mysql_num_fields($result);


echo "<table border='1'><tr>";

echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
echo "<tr>";

foreach($row as $cell)
echo "<td>$cell</td>";

echo "</tr>\n";
}
mysql_free_result($result);
echo "</table>";
}

 

I set it up to display all users, their id, and their online status (0 for no, 1 for yes).

There are two problems so far.

1. The table doesn't display the first user when the entire table is displayed (the first user would be row 0 if that helps)

2. The same problem as above, except it happens when the sql query includes "WHERE online > 0"

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/119088-need-help-with-users-online/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.