Searching and Filtering in CodeIgniter — a practical guide to CodeIgniter search filter with clear examples you can reuse in real projects.
CodeIgniter Tutorial Series (40/74). Prefer one article? Read the complete CodeIgniter tutorial.
Short description
Read `q` from the request and apply `like` / `where` conditions before pagination.
Search + paginate
$q = $this->request->getGet('q');
$model = new AppModelsPostModel();
if ($q) {
$model->like('title', $q);
}
$data['posts'] = $model->paginate(10);
$data['pager'] = $model->pager;
$data['q'] = $q;