first be gentle im a begginer.
I have a problem with codeogniter pagination and im totally clules.
I watched a lot of tuts on the net and never got any aswer.
My problem is, im building a real-estate site, it has 2 types of estate, for sale and for rent.
My query looks like this
function for_sale()
{
$query = $this->db->query(" SELECT city, rand_id, price, image FROM estate WHERE type = 'for_sale' ");
if ($query->num_rows() > 0)
{
foreach ($query->result() as $f)
{
$for_sale[] = $f;
}
return $for_sale;
}
}
my controller
function index()
{
$this->load->view("header");
$this->load->model('estate_model');
$for_sale['result'] = $this->estate_model->for_sale();
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/kpi/for_sale/index';
$config['total_rows'] = 22;
$config['per_page'] = 9;
$config['num_links'] = 19;
$this->pagination->initialize($config);
// $data['records'] = $this->db->get('ingatlan', $config['per_page'], $this->uri->segment(3));
$this->load->view("for_sale_view", $for_sale);
$this->load->view("footer");
}
and my view
foreach($results as $r) {
echo '<div class="grid_4">';
echo '<p class="title">Estate for sale</p>';
echo '<div class="thumbnail">
<div class="info">
<p class="bar">'.$r->city.'</p>
<p></p>
</div>
<a href="#">'.$r->image.'</a></div>';
echo '<div class="more"><a href="#">View details</a></div>';
echo '</div>';
}
So my problem is i cant figure this out how to use it with my query, i watched lots of tuts, that i need to load in the table library, and pass a data array like this
$data['records'] = $this->db->get('estate', $config['per_page'], $this->uri->segment(3));
anf give the per page this result `$this->db->get('estate')->num_rows(); but i would like this with my query, and not with a table.
So can someone hive me a hint?
Thank you