The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
need if conditional....
For this chat script, I need an if conditional so when there are no names to display, it says "No members in Chat".
Also, if you can figure out how to use the usergroup html markup for usernames (ex: like bold names for usergroups that have bold names in online box) that would be great. --------------------------------------------- function usersinroom( $room = "" ) { $cms = $GLOBALS['fc_config']['cms']; $list = array(); if($room) { $stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?"); $rs = $stmt->process($room); } else { $stmt = new Statement("SELECT userid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL"); $rs = $stmt->process(); } while($rec = $rs->next()) $list[] = array_merge($cms->getUser($rec['userid']), $rec); return $list; } ------------------- then is says: ------------------- $users = usersinroom(); $arr = array(); foreach( $users as $user ) { echo "<a href=\"member.php?userid=$user[userid]\">$user[login]</a>"; } ========================= thanks |
#2
|
||||
|
||||
Change
PHP Code:
PHP Code:
|
#3
|
|||
|
|||
No, this caused the page to be just a white page. Code error somewhere.
|
#4
|
||||
|
||||
foreach is a loop, not a conditional. Therefore:
PHP Code:
|
#5
|
|||
|
|||
Hi
You should really be checking if the query returns any thing, there is no sense doing a while() loop on a null returned result set! Also it would be better to do the link building inside the usersinoom() function and just return the links or if no users are in the room, just return "No Users In Room". It wasted coding to do (2) loops and if()s when you don't have to! Logic is missing from this!!! Show me or tell me the database class you are using, and I will writre you how to do it the right way! I need to know the DB class to see if it has a function that returns the row count for the query! Sonia! |
#6
|
|||
|
|||
Thanks if you can help. Here's the whole page. PS - I'm also trying to see if it's possible to add the html markup, like if usernames are bold, etc. Thanks
PHP Code:
Added to post: Quote:
Anyone know how to add the html markups to the usernames? Like, if a name is bolded, it can show the bolded names in the who's chatting, so it matches the who's online? Thanks! Also, I didn't post the whole code before, so can you tell me if what you gave me as the fix is correct? PHP Code:
thanks |
#7
|
||||
|
||||
The usergroup markup requires global.php from vBulletin to be included and then it is a function. I forgot the name of the function, though. I know it contains 'musername' and it in includes/functions.php, though.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|