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 WHERE UNIX_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 And a last question: I always seem to get stuck on mysql queries when scripting. mysql.com gives me a headache whens earching something. Does someone know a good mysql manual site or a good mysql book? Thx in advance Reinhart _____ Reinhart Viane <mailto:rv@xxxxxxxx> rv@xxxxxxxx Domos || D-Studio Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 -- fax +32 15 43 25 26 STRICTLY PERSONAL AND CONFIDENTIAL This message may contain confidential and proprietary material for the sole use of the intended recipient. Any review or distribution by others is strictly prohibited. If you are not the intended recipient please contact the sender and delete all copies.