vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Trying to change some friends list code. (https://vborg.vbsupport.ru/showthread.php?t=225378)

LCN2007 10-16-2009 01:39 PM

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;
}


Lynne 10-16-2009 01:58 PM

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.

LCN2007 10-16-2009 02:17 PM

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?

LCN2007 10-19-2009 12:37 PM

No one?

Thanks


All times are GMT. The time now is 09:56 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.02101 seconds
  • Memory Usage 1,726KB
  • 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_html_printable
  • (1)bbcode_php_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