Skip to Content
PHPCODE
CodeIgniter Project Completed.
codeigniter code / August 8, 2018

Project Complated in codeignter

step 1 : created articlsmodel.php function find in model
{
$q=$this->db->from(‘articles’)
->where([‘id’=>$id])
->get();
if($q->num_rows())
return $q->row();
return false;
}
step 2 : created user.php function find in controller
public function article($id )
{
$this->load->helper(‘form’);
$this->load->model(‘articlesmodel’,’articles’);
$article=$this->articles->find($id);
$this->load->view(‘public/article_detail’,compact(‘article’));
}
step 3: created article_detail.php in view

<?php include_once(‘public_header.php’);?>
<div class=”container”>
<div class=”row”>
<div class=”col-lg-6″>
<h1>
<?= $article->title;?>
</h1>
</div>
<div class=”col-lg-6″>
<span class=”pull-right”>
<?= date(‘d M y H:i:s’,strtotime($article->created_at))?>
</span>
</div>
</div>
<hr>
<p>
<?= $article->body;?>
</p>
</div>

<?php include_once(‘public_footer.php’);?>

step 4 created article_list.php in view

<?php include (‘public_header.php’);?>
<div class=”container”>
<h1>All Articles</h1>
<table class=”table”>
<thead>
<tr>
<td>Sr No.</td>
<td>Article Title</td>
<td>Published On</td>
</tr>
</thead>
<tbody>
<tr>
<?php if(count($articles)):?>
<?php $count=$this->uri->segment(3,0);?>
<?php foreach($articles as $article ):?>
<td><?= ++$count?></td>
<td><?= anchor(“user/article/{$article->id}”,$article->title)?></td>
<td><?= date(‘d M y H:i:s’,strtotime($article->created_at))?></td>
</tr>
<?php endforeach;?>

<?php else: ?>
<tr>
<td colspan=”3″> No Records Found.</td>
</tr>
<?php endif;?>
</tbody>
</table>
<?= $this->pagination->create_links()?>
</div>

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

PHPCODE © 2023