View Full Version : How do a add a location search to the memberlist?
Parker Clack
Mon 19th Feb '01, 5:03am
In the memberlist.php file you have conditions for username, email, etc. but I would like to add a condition for a member's location.
For email there is:
if ($email!="") {
$condition.=" AND email LIKE '%".addslashes($email)."%' ";
}
what statement would I make to add $location?
I know where to add this in the template so that it is inputed but I am not sure what to add to the above.
Thanks,
Parker
Freddie Bingham
Mon 19th Feb '01, 12:55pm
You have to check the userfield table to see which field is your Location. I believe it is 'field2' by default.
[code]
if ($location) {
$condition.=" AND field2 LIKE '%".addslashes($location)."%'";
}
Mitrofan
Mon 19th Feb '01, 1:05pm
I think this should be included in the next release.
The option to add custom member fields as conditions for searches.
Freddie Bingham
Mon 19th Feb '01, 1:07pm
It was on the TODO list but got bumped to v 2.1
memberlist:
- Support for searching custom profile fields. Add an "issearchable" to custom settings options and then add custom fields as
needed to the memberlist advanced search.
Parker Clack
Mon 19th Feb '01, 7:53pm
Freddie:
I used:
if ($location!="") {
$condition.=" AND field2 LIKE '%".addslashes($location)."%'";
}
and got a database error.
Any other ideas?
Thanks,
Parker
Freddie Bingham
Mon 19th Feb '01, 7:59pm
And the error was?
Perhaps it is the lack of a space before the last "
Parker Clack
Tue 20th Feb '01, 10:09am
Freddie:
I used the following
if ($location!="") {
$condition.=" AND field2 LIKE '%".addslashes($location)."%' ";
}
I put in Missouri in for the location and I get back
<!-- Database error in vBulletin: Invalid SQL: SELECT COUNT(*) AS users FROM user WHERE 1=1 AND field2 LIKE '%Missouri%'
mysql error: Unknown column 'field2' in 'where clause'
mysql error number: 1054
so I can see that it being told to look in the user table instead of the userfield table where field2 is located.
Can I add something to the condition call so that it looks for field2 in the userfield table instead?
Thanks,
Parker
Freddie Bingham
Tue 20th Feb '01, 11:49am
Oh I see the problem..
change this line
$userscount=$DB_site->query_first("SELECT COUNT(*) AS users FROM user WHERE $condition");
to:
$userscount=$DB_site->query_first("SELECT COUNT(*) AS users FROM user,userfield WHERE $condition AND user.userid = userfield.userid");
Parker Clack
Tue 20th Feb '01, 6:51pm
Freddie:
That did it!
BTW, I asked this elsewhere but nobody had any ideas for me. I am having trouble with getting my email to work. It worked fine with version 1.1.4 but none of the email functions work with 2.0 beta. Is there something that I need to set somewhere to get this to work. The only thing that I can figure out is that the script might be looking for SMTP instead of sendmail. I use sendmail for emailing off the server as the SMTP has never been set up. Any ideas?
Thanks for all the help.
Parker
Freddie Bingham
Tue 20th Feb '01, 6:58pm
I don't believe we changed any of the email functions.
vBulletin® v3.8.0 Beta 3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.