j.g. Posted August 10, 2007 Share Posted August 10, 2007 Hello List! I've got an issue that I'm hoping someone can help me with... In my db I have 2 fields: first_name and last_name & I want to combine these 2 fields in my drop-down menu. What I have now is showing only the first_name -- I know that it needs to go into the third option in here, I'm just not sure how to get both of them into it. I can get the first_name OR last_name, but not combined. $show_blank = true; $query = "SELECT users.first_name, users.last_name, classification.* FROM users, classification, address ". "WHERE type = 'Membership' ". "AND member_searchable = '1' ". "AND users.classification_id = classification.classification_id ". "AND users.work_address_id != '' ". "AND users.work_address_id = address.address_id ". "ORDER BY users.last_name"; echo query_dropdown($query, 'first_name', 'first_name', "name", $_REQUEST["name"], $show_blank); Any insight and help that you could give me would be greatly appreciated! Thanks, -j.g. Quote Link to comment https://forums.phpfreaks.com/topic/64332-solved-how-to-combining-2-db-fields-into-one-selection/ Share on other sites More sharing options...
akitchin Posted August 10, 2007 Share Posted August 10, 2007 you could concatenate them within the query, and give them another alias so as to preserve the first and last names individually (in case you use them elsewhere): $query = "SELECT users.first_name, users.last_name, CONCAT(users.first_name, ' ', users.last_name) AS full_name classification.* FROM users, classification, address ". "WHERE type = 'Membership' ". "AND member_searchable = '1' ". "AND users.classification_id = classification.classification_id ". "AND users.work_address_id != '' ". "AND users.work_address_id = address.address_id ". "ORDER BY users.last_name"; you're then free to use full_name however you please. Quote Link to comment https://forums.phpfreaks.com/topic/64332-solved-how-to-combining-2-db-fields-into-one-selection/#findComment-320740 Share on other sites More sharing options...
j.g. Posted August 10, 2007 Author Share Posted August 10, 2007 Thanks so much, akitchin! It works!! Have a super weekend! -j.g. Quote Link to comment https://forums.phpfreaks.com/topic/64332-solved-how-to-combining-2-db-fields-into-one-selection/#findComment-320747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.