I've searched the forum and archive area for any idea on how to get the who's online to display not a count but an actual list of the usernames.
This is what I have so far:
include ("config.php");
$Session_name="default";
session_name("$Session_name");
session_start("$Session_name");
$SID = session_id();
$time = time();
$ay = date("z");
$nu = time()-900;
//This connects to the MySQL server
mysql_connect ($dbhost, $dbusername, $dbpass) OR DIE ("Could not connect to MySQL");
mysql_select_db($db_name) OR DIE ("Can't select database.");
$sidcheck = @("SELECT count() FROM useronline WHERE SID=$SID");
$sid_check = @mysql_result($sidcheck,0);
if ($sid_check == "0") {
mysql_query($db_name,"INSERT INTO useronline VALUES ('$time','$REMOTE_ADDR','$PHP_SELF','$username','$id','$time','$ay','$SID')");
}
else{
mysql_query("UPDATE useronline SET time='$time' WHERE SID='$SID'");
}
$count_users = mysql_query("SELECT count() FROM useronline WHERE time>$nu AND ay=$ay");
$users_online = mysql_result($count_users,"0");
mysql_query("DELETE FROM useronline WHERE time<$nu");
mysql_query("DELETE FROM useronline WHERE ay != $ay");
mysql_close();
if ($users_online == "0");
{
$users_online="$username";
}
if ($users_online >"0");
{
$on_string = "<ul>";
$get_contacts_bdo="SELECT SID FROM useronline WHERE time>$nu AND ay=$ay";
$get_contacts_bd1=@($get_contacts_bdo,$connection) or die ("Couldn't execute this damn thing again.");
while($get_contacts2=@mysql_fetch_array($get_contacts_bd1))
{
$contacts_bd_res2 = @($get_contacts_bdo,$connection) or die ("Couldn't execute query again for the third time.");
while ($contacts_bd2 = mysql_fetch_array($contacts_bd_res2))
{
$contact_id2 = $contacts_bd2['id'];
$contact_username2 = $contacts_bd2['username'];
$contact_city2 = $contacts_bd2['city'];
$contact_state2 = $contacts_bd2['state'];
$contact_bd_month2 = $contacts_bd2['month'];
$contact_bd_date2 = $contacts_bd2['date'];
$on_string .="<a href=\"show_contact.php?id=$contact_id2\">$contact_username2</a>";
}
$on_string .="</ul>";
}
It's still all in development. At the end of the script I have it say "The following Members are online $on_string.
It won't show anything. Any ideas would be very helpful.
Thanks,
Michael