Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-21-2002, 01:08 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Memberlist Search

Can anyone please tell me how to make the following code to a partial serach for a member instead of having to have the full member name first?

Code:
if ($action=="quickfind") {
	$usernamecheckq = $DB_site->query("SELECT userid FROM user WHERE username='".addslashes(htmlspecialchars($membername))."'");
	$usernamecheck = mysql_fetch_array($usernamecheckq);
if (!$usernamecheck[userid]) {
	eval("standarderror(\"".gettemplate("error_invalidusername")."\");");
	exit; }
$goto="member.php?s=$session[sessionhash]&action=getinfo&userid=$usernamecheck[userid]";
eval("standardredirect(\"".gettemplate("redirect_memberfound")."\",\"$goto\");");
}
Reply With Quote
  #2  
Old 08-21-2002, 03:51 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

instead of username='".addslashes($membername)."'
use username LIKE '%".addslashes($membername)."%'
Reply With Quote
  #3  
Old 08-21-2002, 06:18 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, that worked, thank you. Now, how can I pull out the full username from the search and display it in the "redirect_memberfound" template. If I use "$membername" like it is now, it pulls out what was in the search string (like boofos ba) instead of the full username. Also, is there a way to have it bring up a listing of just the names found in the search so the user can pick from them?

Quote:
Originally posted by Xenon
instead of username='".addslashes($membername)."'
use username LIKE '%".addslashes($membername)."%'
Reply With Quote
  #4  
Old 08-21-2002, 08:25 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you have to construct a while loop to get all usernames...

to get the correct username instead of $membername use $usernamecheck[username]
Reply With Quote
  #5  
Old 08-21-2002, 09:07 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, but will that do an excessive amount of queries then?

I tried using $usernamecheck[username] and all I get is a blank spot where the name should be.

Quote:
Originally posted by Xenon
you have to construct a while loop to get all usernames...

to get the correct username instead of $membername use $usernamecheck[username]
Reply With Quote
  #6  
Old 08-22-2002, 10:35 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no, no great ammount of queries, just one query and then just fetcharrays

oh sorry, you must include ,username in the query: SELECT userid,username FROM...
Reply With Quote
  #7  
Old 08-22-2002, 06:47 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, Stefan, now it brings up the username ok.

How do I get it to bring up the user alphabetically instead of going by the userid? Right now a user with a Marj in the name comes up before an Marc when I type Mar. It is going by when they joined right now.

Quote:
Originally posted by Xenon
no, no great ammount of queries, just one query and then just fetcharrays

oh sorry, you must include ,username in the query: SELECT userid,username FROM...
Reply With Quote
  #8  
Old 08-22-2002, 06:56 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

add a "ORDER BY username" into the query
Reply With Quote
  #9  
Old 08-22-2002, 07:02 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I take it from my DB error, I put it in the wrong place?

PHP Code:
$usernamecheckq $DB_site->query("SELECT userid,username FROM user ORDER BY username WHERE username LIKE '%".addslashes(htmlspecialchars($membername))."%'"); 
Quote:
Originally posted by Xenon
add a "ORDER BY username" into the query
Reply With Quote
  #10  
Old 08-22-2002, 07:15 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
SELECT userid,username FROM user WHERE username LIKE '%".addslashes(htmlspecialchars($membername))."%' ORDER BY username
shoud be right
Reply With Quote
Reply

Thread Tools
Display Modes

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:27 AM.


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.04414 seconds
  • Memory Usage 2,256KB
  • 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
  • (2)bbcode_code
  • (1)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete