Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Darrell3831
Worker
Worker



Joined: Feb 18, 2004
Posts: 244

PostPosted: Sun Aug 22, 2004 8:41 pm Reply with quote

Hi,

I need to write my own php function to allow an admin in a module I'm writing to search the nuke_users table for a user.

Can someone suggest a piece of code that does a search of such potetntially large tables that I could look at?

I tried to understand the forums search for a member function in the private message stuff, but that's entirely to complicated for me to grasp on my own.

It's neat though... Very Happy I like it. I just don't understand it.. lol

Any examples of something more manageable for a first module??

Thanks,
Darrell

_________________
http://www.psy-center.com 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sun Aug 22, 2004 9:37 pm Reply with quote

Use the LIKE operator.

SELECT * FROM nuke_users WHER username LIKE '%darr%';

will return all hits that have 'darr' ANYWHERE in the username.

LIKE 'darr%' = starts with 'darr'.
LIKE '%darr' = ends with 'darr'.

So, you could write a function like this.

function findUser($name) {
$sql = "SELECT * FROM nuke_users WHER username LIKE '%$name%';";
return $sql;
}

Then call it like this.

$sql = findUser('darr');


Or even

function findUser($name) {
$sql = "SELECT * FROM nuke_users WHER username LIKE '$name';";
return $sql;
}

Then call it like this.

$sql = findUser('%darr%');

That way you can determine, in your module code, what kind of a search you want to do.
 
View user's profile Send private message
Darrell3831







PostPosted: Sun Aug 22, 2004 10:29 pm Reply with quote

Thank you!

I'm gonna try to design something based on that. I appreciate the examples.

How many results do you think I could safely put into a drop down pick list?

Darrell
 
Raven







PostPosted: Sun Aug 22, 2004 11:40 pm Reply with quote

Well I don't know how many users you have or how many will be pulled, but I can't see where you should have much problem with any number. But, if you are just after username searches, maybe this would work http://www.ravenphpscripts.com/download-file-63.html . That's the old v6 members list. I use that one much more than the v7 one.
 
Darrell3831







PostPosted: Mon Aug 23, 2004 8:09 am Reply with quote

Thanks!

I tested the drop down pick list out to 188 names. That was the largest group I could pull from my userlist. It worked.

I can imagine big sites where a person asked for LIKE 'd%' returning a large list.

Very Happy

Darrell
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©