![]() |
DB Query Returns - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: DB Query Returns (/showthread.php?tid=3740) |
DB Query Returns - El Forum - 10-19-2007 [eluser]Daburn[/eluser] Hi Guys I'm trying to become acquainted with CodeIgniter but now facing a problem with the returns of my DB query. I want to give all the values with no content the value "keine Angaben". Because else, the table cells with no content won't be draw. My Model: Code: function list_stocks() { My Controller: Code: $this->load->model('Home_model','', TRUE); Obviously, $query returns an object, but I'm not sure how to realise it else without addressing each result separately with: Code: if ($row->name == "") $row->name = " " Thanks a lot, Daburn DB Query Returns - El Forum - 10-19-2007 [eluser]ELRafael[/eluser] [quote author="Daburn" date="1192821087"]Hi Guys I'm trying to become acquainted with CodeIgniter but now facing a problem with the returns of my DB query. I want to give all the values with no content the value "keine Angaben". Because else, the table cells with no content won't be draw. My Model: Code: function list_stocks() { change this Code: if (strlen($value->the_field_of_stocks_table) == 0) $value = "keine Bier heute :("; The rest is the best :-P [quote author="Daburn" date="1192821087"] My Controller: Code: $this->load->model('Home_model','', TRUE); Obviously, $query returns an object, but I'm not sure how to realise it else without adressing each result separately with: Code: nameindustry == "") $row->name = " " Thanks a lot, Daburn[/quote] DB Query Returns - El Forum - 10-19-2007 [eluser]Daburn[/eluser] Hi ELRafael, Thank you for your answer, but how can i address the current "the_field_of_stocks_table"? Regards, Daburn DB Query Returns - El Forum - 10-19-2007 [eluser]ELRafael[/eluser] what? i didn't understand, sorry. What the field of the table stocks? You should have fields like id, name, or something like that joe! If a value came blank (strlen = 0), you put No Details, right? Probably your field is close to details, hum? Sorry man, but my english is not pretty good! But i try hard to help DB Query Returns - El Forum - 10-19-2007 [eluser]Daburn[/eluser] Jup, I have different fields like id, name, symbol, price etc. I now can do it like: Code: if (strlen($value->id) == 0) $value = "keine Bier heute :("; So I want to solve that with a loop. Something like Code: foreach (go through all the fields of stocks) { ![]() DB Query Returns - El Forum - 10-19-2007 [eluser]ELRafael[/eluser] ah! now i got it :cheese: Are you using MySQL??? if yes, you can use a desc statement Let'me see. My table TB_NAMES +---------+-------------+ | Field | Type | +---------+-------------+ | id | int(4) | | name | varchar(20) | | surname | varchar(30) | +---------+-------------+ So, i can use a DESC Code: $sql = "DESC TB_NAMES"; Sorry, but here i'm using MS SQL, so if i need something, i can get in the sys_ tables. But this should work. Maybe i'll be late to answer again!!! Lunch time here now (13:00pm) and i wanna see a sport show in tv (about brazil x equador). But i'll be back! |