vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Memberlist Search (https://vborg.vbsupport.ru/showthread.php?t=42562)

Boofo 08-21-2002 01:08 AM

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\");");
}


Xenon 08-21-2002 03:51 PM

instead of username='".addslashes($membername)."'
use username LIKE '%".addslashes($membername)."%'

Boofo 08-21-2002 06:18 PM

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)."%'


Xenon 08-21-2002 08:25 PM

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

to get the correct username instead of $membername use $usernamecheck[username]

Boofo 08-21-2002 09:07 PM

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]


Xenon 08-22-2002 10:35 AM

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...

Boofo 08-22-2002 06:47 PM

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...


Xenon 08-22-2002 06:56 PM

add a "ORDER BY username" into the query

Boofo 08-22-2002 07:02 PM

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

Xenon 08-22-2002 07:15 PM

Code:

SELECT userid,username FROM user WHERE username LIKE '%".addslashes(htmlspecialchars($membername))."%' ORDER BY username
shoud be right ;)

Boofo 08-22-2002 07:20 PM

I'm getting this error now. :)

Parse error: parse error, unexpected T_STRING in /home/boofo/public_html/forum/memberlist.php on line 320

Xenon 08-22-2002 07:23 PM

try now ;)

Boofo 08-22-2002 07:27 PM

Still giving me errors. Here is what I have for that whole line now. What did I screw up? :)

PHP Code:

$usernamecheckq $DB_site->query("SELECT userid,username FROM user WHERE username LIKE '%".addslashes(htmlspecialchars($membername))."%' ORDER BY username); 


Xenon 08-22-2002 07:45 PM

add a " before the final ) ;)

Boofo 08-22-2002 07:49 PM

Just shoot me. :) How in the heck could I miss something so obvious? I figured it out at the exact same time my Outlook pulled for mail and your message here showed up. This calls for a big DOOHHH!!!!! Thanks, Stefan. You would think I would learn, huh? :)

Quote:

Originally posted by Xenon
add a " before the final ) ;)


All times are GMT. The time now is 07:15 PM.

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.01109 seconds
  • Memory Usage 1,748KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (15)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