Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 11:58 am EST
Geeklog Forums
searching users
luke
Anonymous
is there anyway to allow users to search users,
i'm trying to set up and artist network type thing and it would be good if users could type into search.... for example "college name" and find all the users on the site that go to that college.
please help have been stuck on this for awhile
thanks luke
i'm trying to set up and artist network type thing and it would be good if users could type into search.... for example "college name" and find all the users on the site that go to that college.
please help have been stuck on this for awhile
thanks luke
8
9
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
User data (from the user's profile) is currently not included in the search. It shouldn't be too hard to add that by either hacking the search class or implementing it as a plugin, though.
bye, Dirk
bye, Dirk
9
8
Quote
Status: offline
suprsidr
Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
There is a function to do that already. I use it in a block, but you could call it wherever you want.
{
global $_CONF, $_TABLES;
if (!empty($_GET['username'])){
$username = COM_applyfilter($_GET['username']);
//query db for matches
$result = DB_query("SELECT uid, username FROM {$_TABLES['users']} WHERE username LIKE '%$username%'");
if (DB_numRows($result) >= 1){
$list = '<p>Results:</p>';
$list = '<ul>';
while ($A = DB_fetchArray($result)){
$list .= '<li><a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">' . COM_stripslashes($A['username']) . '</a></li>';
}
$list .= '</ul>';
$list .= '<p>Search Again?</p>';
}
}
//display form
$form = '<div id="username-search">';
$form .= '<form action="' . $_PHPSELF . '" method="GET">';
$form .= '<input type="text" size="12" name="username">';
$form .= '<input type="submit" value="search">';
$form .= '</form></div>';
//return block
return $list . LB . $form;
}
Hope this helps
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
Text Formatted Code
function phpblock_usernameSearch(){
global $_CONF, $_TABLES;
if (!empty($_GET['username'])){
$username = COM_applyfilter($_GET['username']);
//query db for matches
$result = DB_query("SELECT uid, username FROM {$_TABLES['users']} WHERE username LIKE '%$username%'");
if (DB_numRows($result) >= 1){
$list = '<p>Results:</p>';
$list = '<ul>';
while ($A = DB_fetchArray($result)){
$list .= '<li><a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">' . COM_stripslashes($A['username']) . '</a></li>';
}
$list .= '</ul>';
$list .= '<p>Search Again?</p>';
}
}
//display form
$form = '<div id="username-search">';
$form .= '<form action="' . $_PHPSELF . '" method="GET">';
$form .= '<input type="text" size="12" name="username">';
$form .= '<input type="submit" value="search">';
$form .= '</form></div>';
//return block
return $list . LB . $form;
}
Hope this helps
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
10
9
Quote
All times are EST. The time is now 11:58 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content