![]() |
how is convert this code to CodeIgniter code? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: how is convert this code to CodeIgniter code? (/showthread.php?tid=43520) |
how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]SaSa[/eluser] how is convert this code to CodeIgniter code: search_hotel: -> this is CI_Model Code: return mysql_query("select * from hotel_submits where name LIKE '".$searchterm."'") Code: $query = $this->db->order_by("id", "desc")->like('name', '$searchterm')->get('hotel_submits'); Quote:A PHP Error was encountered code:-> this is CI_Controller Code: $searchterm = $this->input->post('search_hotel'); how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]DirkZz[/eluser] No offence, but you constantly ask things that can be found with basic PHP knowledge or by just reading the User Guide. You can't learn anything if you let other people fix all of your problems. how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]SaSa[/eluser] I tried and more search but I not could. I am involved it in a few days. please help me... how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]Eric Barnes[/eluser] You just need to make sure your query actually generates results before you loop it. Also: Code: $query = $this->db->order_by("id", "desc")->like('name', '$searchterm')->get('hotel_submits'); Code: $query = $this->db->order_by("id", "desc")->like('name', $searchterm)->get('hotel_submits'); how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]SaSa[/eluser] Thank you, what is this error? Code: A PHP Error was encountered line 19: Code: while($row = mysql_fetch_array($query)) //this is line 19 how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]Eric Barnes[/eluser] Sorry just looked at your code again. You will need to read the user guide -> database section. Looks like you are trying to mix straight php sql functions with CodeIgniters. how is convert this code to CodeIgniter code? - El Forum - 07-14-2011 [eluser]SaSa[/eluser] I read about it but did not. please help, I'm haste how is convert this code to CodeIgniter code? - El Forum - 07-15-2011 [eluser]Zaher Ghaibeh[/eluser] can you put your full code so we can spot the error ?? since if you want to get an array out of your code you can use Code: $query->result_array(); Code: return $query->row(); but if you want to get all the results you have to use Code: $query->result(); how is convert this code to CodeIgniter code? - El Forum - 07-15-2011 [eluser]Mat-Moo[/eluser] Your mixing "Active records" with basic sql, you need something more like Code: foreach ($result->result() as $row) ![]() http://ellislab.com/codeigniter/user-guide/database/active_record.html First section on the get() has a better example |