vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Query 'how is on-line'? (https://vborg.vbsupport.ru/showthread.php?t=56876)

cecov74 09-08-2003 04:04 PM

Query 'how is on-line'?
 
What is the query to know hos is on-line?

cecov74 09-09-2003 07:36 AM

I have do

PHP Code:

<?
include ('config2.inc.php');

$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri nel file config.inc.php");
mysql_select_db($db_name, $db)
or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php");

$query = "SELECT access.userid, access.forumid, access.accessmask, user.userid, user.username FROM access, user
WHERE access.userid = user.userid
AND access.accessmask != 0
ORDER BY user.username";

$result = mysql_query($query, $db);

while ($row = mysql_fetch_array($result)) 

{ echo "<font face=Tahoma size=2>" . $row[username] . " , </font>"; }

mysql_close($db);

?>

but I see the name of member 2/3/4 time

"Antonio, Antonio, Antonio, BILL, FREDD, FREDD, ecc..."
I want see only ther first record, If there is the same don't do a print :(

Issvar 09-13-2003 06:55 PM

Code:

$query='SELECT DISTINCT session.userid,user.username FROM session LEFT JOIN user ON user.userid=session.userid WHERE user.invisible=0 AND session.userid>0 AND ('.time().'-session.lastactivity-1500)<0 ORDER BY user.username';
The 1500 is the timeoutvalue of your cookies, you should set this to match your board setting (or get it from the option table in a seperate query).

Access table has nothing to do with who is online.

When you have more than one table in your query use JOIN to join them or you might get too many results back.

Use distinct keyword to only get unique results.


All times are GMT. The time now is 04:30 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01144 seconds
  • Memory Usage 1,712KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete