daximus Posted March 10, 2010 Share Posted March 10, 2010 So i'm trying to query a wordpress database that looks like this: | user_id | meta_key | meta_value | | 1 | state | CA | | 1 | practice | bankruptcy | | 2 | state | NY | | 2 | practice | employment | etc. I want my users to be able to search by both state and practice using two separate dropdown menus. I don't know enough about PHP to know how to write the query. I am able to return results for either state OR practice, i just don't understand how to return results for state AND practice. What I used to return results for just practice is: ("SELECT ID FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'practice' AND meta_value REGEXP '$LFPA')") $LFPA is the practice area which is grabbed from the form the user submits. So basically, i'm trying to get the user_id's (sometimes multiple, sometimes only one or none) which correspond to both the practice area and state that has been selected, and then i'm going to return more information based on those user_id's. Any help would be greatly appreciated. Thanks! Dax Link to comment https://forums.phpfreaks.com/topic/194796-having-trouble-querying-my-wordpress-database/ Share on other sites More sharing options...
BRIK Posted March 10, 2010 Share Posted March 10, 2010 I dont know PHP well enough but know a bit about SQL queries. (I'm trying to give back since i just posted a question) I would start by writing the query you want outside of PHP first using query browser to make sure you get the results you want. Good luck, i that little bit of not too useful advice can help just a little. Link to comment https://forums.phpfreaks.com/topic/194796-having-trouble-querying-my-wordpress-database/#findComment-1024358 Share on other sites More sharing options...
daximus Posted March 10, 2010 Author Share Posted March 10, 2010 Thanks for the suggestion BRIK. I'm still not having any luck... Anyone else? Thanks. Dax Link to comment https://forums.phpfreaks.com/topic/194796-having-trouble-querying-my-wordpress-database/#findComment-1024415 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.