FT3 Posted October 25, 2009 Report Share Posted October 25, 2009 (edited) Man vjg parveidot kodu ka lai ustajsa lai ņemtu lietotajus no table users un raditu cik ir online re kods <?php include_once('includes/db_connect.php'); $guests = ''; $users = ''; $link = mysql_connect($INFO['sql_host'],$INFO['sql_user'],$INFO['sql_pass']); mysql_query('use '.$INFO['sql_database'].';'); $now = time()-1050; $result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where member_id = 0 && running_time > '.$now.';'); $r = mysql_fetch_array($result); if ($r[0]>0) { $guests = $r[0]; } else { $guests = 0; } $result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where member_id > 0 && running_time > '.$now.';'); $r = mysql_fetch_array($result); if ($r[0]>0) { $users = $r[0]; } else { $users = 0; } echo 'Lietotāji ('.$users.'), Viesi ('.$guests.')'; mysql_close($link); ?> Edited October 25, 2009 by FT3 Link to comment Share on other sites More sharing options...
homers Posted October 25, 2009 Report Share Posted October 25, 2009 ka lai ustajsa lai ņemtu lietotajus no table users un raditu cik ir online Kā to saprast? Link to comment Share on other sites More sharing options...
rATRIJS Posted October 25, 2009 Report Share Posted October 25, 2009 Vismaz DB struktūru varēji norādīt. Nevar tak vnk iemest random kodu un teikt man vajag uztaisīt to. Ko tu esi darījis lietas labā? Link to comment Share on other sites More sharing options...
FT3 Posted October 25, 2009 Author Report Share Posted October 25, 2009 homers tip lai raditu weba cik cilveki ir ielogojošies un otrs lai raditu cik cilveki nau ielogojošies Link to comment Share on other sites More sharing options...
homers Posted October 25, 2009 Report Share Posted October 25, 2009 <? //konekts $delay = "900"; $delays = time() - $delay; $useri = mysql_query("SELECT * FROM ibf_members WHERE last_activity >= ".$delays.""); $reg = mysql_num_rows($useri); $viesi = mysql_query("SELECT * FROM ibf_sessions WHERE member_id = '0' and running_time >= ".$delays.""); $viesi = mysql_num_rows($viesi); echo ' Viesi: '.$viesi.'<br /> Lietotāji: '.$reg.'<br />'; ?> hz, vai iet Link to comment Share on other sites More sharing options...
FT3 Posted October 25, 2009 Author Report Share Posted October 25, 2009 man nevjg priekš ipb bet meginašu adopdet Link to comment Share on other sites More sharing options...
homers Posted October 25, 2009 Report Share Posted October 25, 2009 (edited) Nu vienkarši nomainot tabulas nosaukumu kodā <? //konekts $delay = "900"; $delays = time() - $delay; $useri = mysql_query("SELECT * FROM TABULA WHERE PEDEJA AKTIVITATE >= ".$delays.""); $reg = mysql_num_rows($useri); $viesi = mysql_query("SELECT * FROM TABULA WHERE id = '0' and LAIKS >= ".$delays.""); $viesi = mysql_num_rows($viesi); echo ' Viesi: '.$viesi.'<br /> Lietotāji: '.$reg.'<br />'; ?> Edited October 25, 2009 by homers Link to comment Share on other sites More sharing options...
FT3 Posted October 25, 2009 Author Report Share Posted October 25, 2009 nekas nesanak ;[[ Link to comment Share on other sites More sharing options...
FT3 Posted October 25, 2009 Author Report Share Posted October 25, 2009 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\v2\includes\online.php on line 8 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\v2\includes\online.php on line 10 Viesi: Lietotaji: erors Link to comment Share on other sites More sharing options...
rATRIJS Posted October 25, 2009 Report Share Posted October 25, 2009 mysql_query("...") or die(mysql_error()); Link to comment Share on other sites More sharing options...
homers Posted October 25, 2009 Report Share Posted October 25, 2009 Vieglākais variants ir šāds: Izveido lietotāja db tabulu online, kad lietotājs ielogojas tabula updeito kolonu online uz vārdu on. Tad pie online izvēlc šadi: mysql_query("SELECT * FROM lietotaji WHERE online='on'"); Bet kad izlogojas tabulā updeitojas kolonu online uz vārdu off Link to comment Share on other sites More sharing options...
FT3 Posted October 25, 2009 Author Report Share Posted October 25, 2009 rATRIJS , nesapratu tevi ;/ Link to comment Share on other sites More sharing options...
rATRIJS Posted October 25, 2009 Report Share Posted October 25, 2009 homers: Un ja neizlogojas? Tad visu mūžu rādīsies kā online. DB vajag glabāt pēdējās aktivitātes laiku un vietā kur atlasa online esošos lietotājus atlasīt tos lietotājus, kuriem pēdējās aktivitātes laiks ir pirms, piemēram, ne vēlāks par 5min FT3: aiz kvērija pieliec to ko rakstīju. Link to comment Share on other sites More sharing options...
FT3 Posted October 25, 2009 Author Report Share Posted October 25, 2009 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AKTIVITATE >= 1256485015' at line 1 wtf ? :D Link to comment Share on other sites More sharing options...
homers Posted October 25, 2009 Report Share Posted October 25, 2009 Un kā saglābat pedejo aktivitāti? Link to comment Share on other sites More sharing options...
Recommended Posts