Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-16-2009, 02:39 PM
LCN2007 LCN2007 is offline
 
Join Date: Jul 2007
Posts: 323
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trying to change some friends list code.

Im trying to modify some code, im hoping someone can help me.

I have this chunk of code that is set to populate a friends list with all (offline/online) members that are on your vbulletin friends list, but i would like to have it set to populate only online friends from can anyone help.

HTML Code:
function getFriendsList($userid,$time) {
	$sql = ("select ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, friends_status.message, friends_status.status from ".TABLE_PREFIX."userlist join ".TABLE_PREFIX."user on  ".TABLE_PREFIX."userlist.relationid = ".TABLE_PREFIX."user.userid left join friends_status on ".TABLE_PREFIX.DB_USERTABLE.".userid = friends_status.userid where ".TABLE_PREFIX."userlist.friend = 'yes' and ".TABLE_PREFIX."userlist.userid = '".mysql_real_escape_string($userid)."' order by username asc");
	return $sql;
}
Reply With Quote
  #2  
Old 10-16-2009, 02:58 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And what are you getting as a result of that code? You didn't tell us what was wrong.



Also, I have watch Sir Adrian write queries many times before and one thing I have learned from watching him is that seeing what is wrong with your query is sooooo much easier if you write it out using multiple lines:
PHP Code:
$sql = ("select ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, friends_status.message, friends_status.status 
from "
.TABLE_PREFIX."userlist 
join "
.TABLE_PREFIX."user on  ".TABLE_PREFIX."userlist.relationid = ".TABLE_PREFIX."user.userid 
left join friends_status on "
.TABLE_PREFIX.DB_USERTABLE.".userid = friends_status.userid 
where "
.TABLE_PREFIX."userlist.friend = 'yes' and ".TABLE_PREFIX."userlist.userid = '".mysql_real_escape_string($userid)."' 
order by username asc"
); 
He also indents and always capitilizes actions - I didn't do that to yours, but I always do that to mine now. It just makes it much easier to read.

I'm not a query person, so I'm not gonna tear it apart to see what is wrong (especially since you never said what was wrong with it), but I did see that youare calling the avatar field from the user table and there is no avatar field in the user table.
Reply With Quote
  #3  
Old 10-16-2009, 03:17 PM
LCN2007 LCN2007 is offline
 
Join Date: Jul 2007
Posts: 323
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nothing is wrong per say i did state what i was looking for help with though.

the code i posted above queries the vb friends list and populates it on a list, this includes on and off line users. If if the user is online a little button or light turns on satting that they are online.

I would like to modify the code to show only online users that are on my friends list.

Sorry i cannot post a picture of the problem because there is not one, im just looking for help to change the code i have.

--------------- Added [DATE]1255787424[/DATE] at [TIME]1255787424[/TIME] ---------------

Does anyone know how to make this query?
Reply With Quote
  #4  
Old 10-19-2009, 01:37 PM
LCN2007 LCN2007 is offline
 
Join Date: Jul 2007
Posts: 323
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No one?

Thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:25 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09189 seconds
  • Memory Usage 2,202KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete