Welcome Guest, Not a member yet? Register   Sign In
how is convert this code to CodeIgniter code?
#1

[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."'")
i try but have error:
Code:
$query = $this->db->order_by("id", "desc")->like('name', '$searchterm')->get('hotel_submits');
        return $query->row();
error:
Quote:A PHP Error was encountered
Severity: Warning
Message: mysql_fetch_assoc() expects parameter 1 to be resource, array given
Filename: admin/tour.php
Line Number: 15


A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: admin/tour.php
Line Number: 21

code:-> this is CI_Controller
Code:
$searchterm = $this->input->post('search_hotel');
        $result = $this->model_tour->search_hotel($searchterm);
        while ($row = mysql_fetch_assoc($result)) { //this is line 15
        //giving names to the fields
        $data = array (
            'name' => $row->name,            
        );
        }
        echo json_encode($data);  //this is line 21


Messages In This Thread
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 09:10 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 09:32 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 09:35 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 10:01 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 10:11 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 10:13 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-14-2011, 10:23 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-15-2011, 02:26 AM
how is convert this code to CodeIgniter code? - by El Forum - 07-15-2011, 07:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB