1
Cuidiu
Search Members by State
  • 2006/4/28 18:13

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


I've decided to keep trying to get the membership site going with XOOPS because it's really such a wonderful CMS. I'm totally awed by it. So, I'm trying to figure out how I can hack XM-Memberstats to search by state along with the other options. Can anyone help? This would help quite a bit. It would be great to add extra fields to the existing fields that show in the listing of members but if that's not possible, a search by state would be great. I could probably add a note to the top that instructs users to search by state by adding the state abbreviation in the search field but it would be nice to have a dropdown or something to that effect.

Any ideas? Could really use some help...

Cuidiu
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

2
sceilig
Re: Search Members by State
  • 2006/5/9 22:41

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


I have been hacking away at XM-Memberstats to show a list of users based on search criteria. I am also using Extended Profiles to manage users and the initial registration form. With Extended Profiles, you can add any number of custom fields, so you could add a dropdown, and then populate with all 50 states as options (all by using the Extended Profiles admin area - bit of a pain but it does work)
e.g.
1 - Alabama
2 - Arizona

Then you would have to hack XM-Memberstats to add a search form, with searching by state one of the criteria. This could be done with the xoopsformloader.php class - much like how other forms are built in xoops.

Then when you run your search, you would have to tweak the MySQL query to search the user_profiles tables for where state = '2' (for users in arizona).

Code would be something like this

Quote:

if ($_POST[state]) $querystate = $xoopsDB->prefix("user_profile").".state = '$_POST[state]."'";
else $querystate = 1;

$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("users")." INNER JOIN ".$xoopsDB->prefix("user_profile")." ON ".$xoopsDB->prefix("users").".uid=".$xoopsDB->prefix("user_profile").".profileid WHERE ".$xoopsDB->prefix("users").".level>0 AND $querystate");


Then loop through the users and display them. to do all this you would have to be comfortable creating a XOOPS search form, building a MySQL query from the search criteria, and looping through the results and displaying them. If not, then I dont think you should tackle it.
The XOOPS documentation on getting up to speed in developing forms using XOOPS classes is minimal and you kindof have to see how other modules display their forms and then replicate the code snippets.

3
Cuidiu
Re: Search Members by State
  • 2006/5/13 15:37

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Thanks sceilig. That was great information. A little beyond me - I think I could do it but not sure it's worth all the effort. I have been using extended profiles and really like it a lot. However, I can't figure out how to add a dropdown list or radio buttons to it. I'm assuming I have to hack one of the files for it to display properly in the registration form...?

As for search by state. Perhaps there is a shortcut. I first tried creating a function for a state listing similar to the alpha function. This did not work because I know only the most basic PHP, if that. So, instead what about something like this:
domain.com/modules/xmmemberstats/index.php?query=CA&sortby=uid
The CA would be the state (unless I add field for that?). Then hack the xmmemberstats/index.php and add a link for each search so that it would appear to the user as so:
Search for members from California:Click here
except use a little mod_rewrite to make the URL shorter:
modules/xmmemberstats/CA/ so that it appears nicer in the browser and so on... I suppose that would also be a pain putting in all 50 states... I'll have to think more on this.
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

Login

Who's Online

253 user(s) are online (146 user(s) are browsing Support Forums)


Members: 0


Guests: 253


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits