antonyfal Posted October 23, 2011 Share Posted October 23, 2011 Hi, Im battling here to get "only" certain values from a "akey" and "value" query.. I have a list of items around 200 id's strong, i only want to pull cirtain values from the list, the table structure is like so: id, akey, value // i don't know the values of the specific akey's or their id's but i do know the akey value. what i am trying to do is only pull the values that are in the "getConfigTitle's" list below (this list is only a sample the actual list is around 100 strong) here is my code sample: $query="SELECT akey,value FROM settings WHERE LOWER(akey) LIKE getConfigTitles();"; $settingsList=doSelectSql($query); foreach ($settingsList as $set) { $r=array(); $r['CONFIGTITLE']=getConfigTitles(); $r['KEY'] = $set->akey; $r['SETTING'] = $set->value; $rows[]=$r; } function getConfigTitles() { $titles=array(); $titles['search']= "search" ; $titles['viewprofile']= "viewprofile" ; $titles['editprofile']= "editprofile" ; $titles['dashboard']= "dashboard" ; $titles['preview']= "preview" ; return $titles; } Quote Link to comment https://forums.phpfreaks.com/topic/249659-retrieve-cirtain-values-from-akey-and-value-query/ Share on other sites More sharing options...
xyph Posted October 23, 2011 Share Posted October 23, 2011 You want to build a query like this SELECT akey,value FROM settings WHERE akey IN ('search','viewprofile','editprofile','dashboard','preview') Quote Link to comment https://forums.phpfreaks.com/topic/249659-retrieve-cirtain-values-from-akey-and-value-query/#findComment-1281614 Share on other sites More sharing options...
antonyfal Posted October 23, 2011 Author Share Posted October 23, 2011 Thanks for the reply. is it that simple?? im going to give it a go.. i was hoping i could use the already made function somehow as there are 100+ specifics i need to get, i wanted to avoid all that writing AGAIN!.. i also have other queries like this one.. In the meantime i will try it this way.. thanks xyph Quote Link to comment https://forums.phpfreaks.com/topic/249659-retrieve-cirtain-values-from-akey-and-value-query/#findComment-1281616 Share on other sites More sharing options...
xyph Posted October 23, 2011 Share Posted October 23, 2011 You can use the given function. Take a look at the array functions PHP has to offer. http://php.net/manual/en/ref.array.php I'm sure there's something in there that involves turning an array into a delimited string Quote Link to comment https://forums.phpfreaks.com/topic/249659-retrieve-cirtain-values-from-akey-and-value-query/#findComment-1281619 Share on other sites More sharing options...
antonyfal Posted October 23, 2011 Author Share Posted October 23, 2011 agg this is working perfectly xyph. It wasn't as hard to create the list as i thought, a little CTRL+H magic and all was 2 minutes worth .. I do like the page you sent me though... lots of interesting stuff there.. Thanks again Best regards Antony.. Quote Link to comment https://forums.phpfreaks.com/topic/249659-retrieve-cirtain-values-from-akey-and-value-query/#findComment-1281629 Share on other sites More sharing options...
xyph Posted October 23, 2011 Share Posted October 23, 2011 Yes, the PHP manual is a great resource. Quote Link to comment https://forums.phpfreaks.com/topic/249659-retrieve-cirtain-values-from-akey-and-value-query/#findComment-1281660 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.