php - how to get field value from database and pass to function? -


I am creating two functions, I want to get $ function as $ id and $ i do this Am I This is my code:

  function getbussinessdetail ($ profit_id) {$ select = "select a.account_id, a.title, a.budget, a.location_4, a.renewal_date, L.name By listing, listing listing L. l.value = a.level and profit_instructor_id = '' $ profit_id. '' Group by A.account_id = $ result = $ global ['mysqli'] - & gt; query ($ selection) ) Or die ($ globals ['mysqli'] -> error. __LINE__); while ($ rs = $ result-> Fitch_sock ()) {$ res [] = $ rs;} $ Res;} Function getCityName ($ id) {if ($ id & gt; 0) {$ select = "location_4 Select name where id = $ id"; $ result = $ global ['mysqli1'] - & gt; query $ Selection) or R ($ globals ['mysqli1'] -> error. __LINE__); $ RS = $ result-> FECH_ASOC (); $ R ['name'] return;}}  

Try this:

  $ profit_id = 4; $ Res = array (); $ Res = getbussinessdetail ($ profit_id); if (count ($ res)> 0) {$ cityNames = array (); Foreign exchange ($ res as $ id) {$ cityNames [] = getCityNames ($ id ['location_4']); }} Var_dump ($ cityNames); Or, just update the first query and get rid of another function:  
  $ select = "a.account_id, a.title, one of Select .budget, a.location_4, a.renewal_date, l.name from the list, listinglL where l.value = a.level and profit_instructor_id = '"$ profit_id."' Group by A.account_id ';  

With this one:

  select $ = "a.account_id, a.title, a.budget, (choose location name where id = A .location_4) As the name of the city, listing a.renewal_date, l.name, listinglevel l where l.value = a.level and profit_instructor_id = '"$ profit_id.' 'A.ac Group by count_id ';  

Comments