[eluser]Unknown[/eluser]
Hello everyone! I am creating a search engine in my blog but I can't count the record and set the pagination. Help me @@
Here is my model
function timkiem($total_pages)
{
$match = $this->input->get('search');
$this->db->like('title',$match);
$this->db->or_like('author',$match);
$timkiem=$this->db->get('entries');
return $timkiem->result();
}
My controller
{
$this->load->model('test');
$data['timkiem'] = $this->test->timkiem($total_pages);
echo $total_pages;
$this->load->view('books', $data);
}
My view
<html>
<body>
<form name="input" action="" method="get">
<input type="text" name='search' />
<input type="submit" value="Search" />
</form>
Search template
<?php echo anchor('blog','Back to blog')?>
<table>
<tr> <th>Title </th> <th>Author</th> </tr>
<?php foreach($timkiem as $item):?>
<tr>
<td><?php echo anchor('blog/view/'.$item->id , $item->title )?></td>
<td><?php echo $item->author?></td>
</tr>
<?php endforeach;?>
</table>
</body>
</html>
Thanks a lot everyone@@