Table chat_online:
session (varchar)
activity (datetime)

Table persons
persons_region_int(int)

Table regions
region_id
region_name

On a page i list all persons which are in the chat_online dbase and
within a certain period: 

$limit_time = time() - 130; // 2 Minutes time out. 60 * 2 = 120 
$sqlchatonline = "SELECT * FROM chat_online WHERE
UNIX_TIMESTAMP(activity) >= $limit_time AND
(sessionid!='".session_id()."')";
$resultchatonline=mysql_query($sqlchatonline) or die (mysql_error()); 
$chatvisits = mysql_num_rows($resultchatonline);
while($rowchatonline = mysql_fetch_object($resultchatonline)){
$chattersessionid=$rowchatonline->sessionid;

//get the username, userid, mainpicid from the online chatter
$getinfo= "select * from persons where
person_session_id='$chattersessionid'";
$resultgetinfo = mysql_query($getinfo) or die (mysql_error());
$rowgetinfo= mysql_fetch_array($resultgetinfo);
echo $rowgetinfo['person_nick'];
}

Now i want these online chatters to be listed by person_region_int:
something like: 
region A
  chatter1
  chatter2
region B
  none
region C
  chatter3
  chatter4

How do i do this?


And a second question:
I have created a menu box which lists all regions, if a option is
selected by the user, i only want to show the online chatters of the
selected region (selecting an option defines a variable $region which
holds the region_id) 

Something like: 
if ($region) { $sqlchatonline = "SELECT * FROM chat_online, persons
WHEREUNIX_TIMESTAMP(chat_online.activity) >= $limit_time AND
(chat_online.sessionid!='".session_id()."' AND
(persons.persons_region_int='$region')";
}
This doe not give me the correct result: it shows all online chatters *
total amount of users of that region. It should be all online chatters
from that specified region.

What can be the correct syntax?



Thx in advance
Reinhart Viane 



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to