php_begins Posted February 6, 2012 Share Posted February 6, 2012 I have the following mysql query: $lead_query=$this->db->query(" SELECT `first_name`, `last_name` , `state` FROM leads WHERE `lead_id`='$lead_id' "); $this->view->lead_query=$lead_query->fetchALL(); Now when I retrieve the above details I need to return the first_name last_name together(separated as space) and the name of the key as client_name in the array. I need it that way because when i return a json_encode($lead_query), I want to return the first_name.last_name as client_name. Quote Link to comment https://forums.phpfreaks.com/topic/256547-concatenate-field-names-into-one-and-return/ Share on other sites More sharing options...
php_begins Posted February 6, 2012 Author Share Posted February 6, 2012 .i dont know how that attached file got uploaded there.. Quote Link to comment https://forums.phpfreaks.com/topic/256547-concatenate-field-names-into-one-and-return/#findComment-1315153 Share on other sites More sharing options...
Maq Posted February 6, 2012 Share Posted February 6, 2012 .i dont know how that attached file got uploaded there.. Deleted. Quote Link to comment https://forums.phpfreaks.com/topic/256547-concatenate-field-names-into-one-and-return/#findComment-1315158 Share on other sites More sharing options...
php_begins Posted February 6, 2012 Author Share Posted February 6, 2012 $lead_query=$this->db->query(" SELECT CONCAT(`first_name`, ' ', `last_name`) AS `client_name` , `state` FROM leads WHERE `lead_id`='$lead_id' "); The above worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/256547-concatenate-field-names-into-one-and-return/#findComment-1315167 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.