vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   selecting 10 random online users (is very difficult) (https://vborg.vbsupport.ru/showthread.php?t=57924)

Tae-Hwan 10-15-2003 09:41 PM

selecting 10 random online users (is very difficult)
 
i have found no simple way to do this. i'd really love to have someone come along and make me feel very, very stupid... because i have been working on this for several days without avail.

SELECT DISTINCT ... ORDER BY RAND(NOW())

does not work on any version of mysql.

Code:

  $loggedins2=$DB_site->query("SELECT DISTINCT session.userid,username,invisible
                              FROM session
                              LEFT JOIN user ON (user.userid=session.userid)
                              WHERE session.userid>0 AND session.lastactivity>$datecut AND invisible != 1
                              ORDER BY RAND(NOW())");

^ this is what i'd like to have on index.php

thanks in advance for your help. :)

Xenon 10-15-2003 10:31 PM

hmm, normally this should work, but you can also try to save the users into an array first and then randomize the array.

NTLDR 10-15-2003 10:58 PM

Works fine for me on MySQL 4.0.15, you'll need to add LIMIT 10 on the end to limit it to just 10 online users though.

Tae-Hwan 10-16-2003 12:35 AM

thanks guys.. i finally got it. :) i had been misled by some other information i had read about the mysql fixes for the "SELECT DISTINCT ... ORDER BY RAND()" errors for 3.23.05


All times are GMT. The time now is 11:16 AM.

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.01059 seconds
  • Memory Usage 1,710KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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