Welcome Guest, Not a member yet? Register   Sign In
Querying the database
#1

[eluser]Wonder Woman[/eluser]
Basically I want to take an input and pass it on to query the database and then bring back the results for the pagination. I want to query a location.
My controller looks like this:

Code:
function index() {
  if($this->validation->run()==FALSE){
    $this->load->view('property_view', $data);
  }
  else {
    $location = $this->input->post('location');
    redirect('property/results');
  }
}

function results() {
  $data['result']=$this->db->get('properties',10,$this->uri->segment(3));
  $config['base_url']=base_url().'/property/results';
  $config['total_rows']=$this->db->count_all('properties');
  $config['full_tag_open']='<div id="pages">';
  $config['full_tag_close']='</div>';
  $this->pagination->initialize($config);
        
  $data['links']=$this->pagination->create_links();
  $this->load->view('property_results',$data);
}


I figure this needs to be changed to put the query where 'properties' is because that is just requesting the database:

Code:
$data['result']=$this->db->get('properties',10,$this->uri->segment(3));

My model looks like:

Code:
function get_properties($num, $offset) {
  $query = $this->db->get('properties', $num, $offset);
  return $query;
}
    
function get_specified_location($location) {
  $this->db->like('town', $location);
  $query = $this->db->get('properties');    
  return $query->result_array();
}


Messages In This Thread
Querying the database - by El Forum - 08-11-2010, 08:04 AM
Querying the database - by El Forum - 08-11-2010, 05:31 PM
Querying the database - by El Forum - 08-12-2010, 03:05 AM
Querying the database - by El Forum - 08-12-2010, 06:38 AM
Querying the database - by El Forum - 08-12-2010, 07:26 AM
Querying the database - by El Forum - 08-12-2010, 07:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB