I have a project on codeigniter. I have to fetch all data from my database. the database is in MYSQL. and i have fetch data in a simple tablular form. I think i have written all code but threre is showing some errors.
What i have tried
controller
public function viewoffers()
{
if(!$this->session->userdata('admin_id'))
return redirect('admin/adminlogin');
$this->load->model('viewoffer');
$offers = $this->viewoffer->viewoffermodel();
$this->load->view('admin/admindash',['offers'=>$offers]);
}
Model
public function viewoffermodel()
{
$q = $this->db->select('*')
->from('offers')
->get();
return $q->result();
}
view
<?php if(count($offers)): ?>
<?php foreach ($offers as $emp): ?>
<tr>
<td><?php echo $emp->offer_id; ?></td>
<td><?php echo $emp->heading; ?></td>
<td><?php echo $emp->details; ?></td>
<td><a href=""><?php echo $emp->link; ?></a></td>
<td><img border="0" height="90" width="130" src="<?php echo $emp->image ?>" class="rounded" alt="..."></td>
<td><?= base_url('admin/delarticles'); ?>/<?php echo $emp->offer_id; ?></td>
<td><?= base_url('admin/editoffer'); ?>/<?php echo $emp->offer_id; ?></td>
<td><?= base_url('admin/index');?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td style="text-align: center; color: red;" colspan="8">Not data available</td>
</tr>
<?php endif; ?>
</tr>
the error i have got
Severity: Notice
Message: Undefined variable: offers
Filename: admin/admindash.php
Line Number: 90
Backtrace:
File: C:\xampp\htdocs\blog\application\views\admin\admindash.php
Line: 90
Function: _error_handler
File: C:\xampp\htdocs\blog\application\controllers\admin.php
Line: 10
Function: view
File: C:\xampp\htdocs\blog\index.php
Line: 315
Function: require_once
THERE IS ANOTHER TYPE OF ERROR I HAVE GOT IN VS CODE EDIDTOR
I have a project on codeigniter. I have to fetch all data from my database. the database is in MYSQL. and i have fetch data in a simple tablular form. I think i have written all code but threre is showing some errors.
What i have tried
controller
public function viewoffers()
{
if(!$this->session->userdata('admin_id'))
return redirect('admin/adminlogin');
$this->load->model('viewoffer');
$offers = $this->viewoffer->viewoffermodel();
$this->load->view('admin/admindash',['offers'=>$offers]);
}
Model
public function viewoffermodel()
{
$q = $this->db->select('*')
->from('offers')
->get();
return $q->result();
}
view
<?php if(count($offers)): ?>
<?php foreach ($offers as $emp): ?>
<tr>
<td><?php echo $emp->offer_id; ?></td>
<td><?php echo $emp->heading; ?></td>
<td><?php echo $emp->details; ?></td>
<td><a href=""><?php echo $emp->link; ?></a></td>
<td><img border="0" height="90" width="130" src="<?php echo $emp->image ?>" class="rounded" alt="..."></td>
<td><?= base_url('admin/delarticles'); ?>/<?php echo $emp->offer_id; ?></td>
<td><?= base_url('admin/editoffer'); ?>/<?php echo $emp->offer_id; ?></td>
<td><?= base_url('admin/index');?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td style="text-align: center; color: red;" colspan="8">Not data available</td>
</tr>
<?php endif; ?>
</tr>
the error i have got
Severity: Notice
Message: Undefined variable: offers
Filename: admin/admindash.php
Line Number: 90
Backtrace:
File: C:\xampp\htdocs\blog\application\views\admin\admindash.php
Line: 90
Function: _error_handler
File: C:\xampp\htdocs\blog\application\controllers\admin.php
Line: 10
Function: view
File: C:\xampp\htdocs\blog\index.php
Line: 315
Function: require_once
THERE IS ANOTHER TYPE OF ERROR I HAVE GOT IN VS CODE EDIDTOR
I have a project on codeigniter. I have to fetch all data from my database. the database is in MYSQL. and i have fetch data in a simple tablular form. I think i have written all code but threre is showing some errors.
What i have tried
controller
public function viewoffers()
{
if(!$this->session->userdata('admin_id'))
return redirect('admin/adminlogin');
$this->load->model('viewoffer');
$offers = $this->viewoffer->viewoffermodel();
$this->load->view('admin/admindash',['offers'=>$offers]);
}
Model
public function viewoffermodel()
{
$q = $this->db->select('*')
->from('offers')
->get();
return $q->result();
}
view
<?php if(count($offers)): ?>
<?php foreach ($offers as $emp): ?>
<tr>
<td><?php echo $emp->offer_id; ?></td>
<td><?php echo $emp->heading; ?></td>
<td><?php echo $emp->details; ?></td>
<td><a href=""><?php echo $emp->link; ?></a></td>
<td><img border="0" height="90" width="130" src="<?php echo $emp->image ?>" class="rounded" alt="..."></td>
<td><?= base_url('admin/delarticles'); ?>/<?php echo $emp->offer_id; ?></td>
<td><?= base_url('admin/editoffer'); ?>/<?php echo $emp->offer_id; ?></td>
<td><?= base_url('admin/index');?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td style="text-align: center; color: red;" colspan="8">Not data available</td>
</tr>
<?php endif; ?>
</tr>
the error i have got
Severity: Notice
Message: Undefined variable: offers
Filename: admin/admindash.php
Line Number: 90
Backtrace:
File: C:\xampp\htdocs\blog\application\views\admin\admindash.php
Line: 90
Function: _error_handler
File: C:\xampp\htdocs\blog\application\controllers\admin.php
Line: 10
Function: view
File: C:\xampp\htdocs\blog\index.php
Line: 315
Function: require_once
THERE IS ANOTHER TYPE OF ERROR I HAVE GOT IN VS CODE EDIDTOR
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.