Skip to Content
CodeIgniter Search Articles
codeigniter code / August 5, 2018

Serach Articles in Codeigniter

step 1:- Created model search function
public function search($query)
return $q->result();
step 2: – created search function in controller
public function search()

if(! $this->form_validation->run())



step 3: created search_results in view

<?php include (‘public_header.php’);?>
<div class=”container”>
<h1>Serach Results</h1>
<table class=”table”>
<td>Sr No.</td>
<td>Article Title</td>
<td>Published On</td>
<?php if(count($articles)):?>
<?php $count=$this->uri->segment(3,0);?>
<?php foreach($articles as $article ):?>
<td><?= ++$count?></td>
<td><?= $article->title?></td>
<td><?= “Date” ?></td>
<?php endforeach;?>

<?php else: ?>
<td colspan=”3″> No Records Found.</td>
<?php endif;?>

<?php include (‘public_footer.php’);?>s

No comments yet, take the initiative.

Leave a Reply

Your email address will not be published.

PHPCODE © 2023