how is convert this code to CodeIgniter code? |
[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');
[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.
[eluser]SaSa[/eluser]
I tried and more search but I not could. I am involved it in a few days. please help me...
[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');
[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
[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.
[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();
[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-gui...ecord.html First section on the get() has a better example |
Welcome Guest, Not a member yet? Register Sign In |