[eluser]shiva478[/eluser]
Hi
I'm trying to view a row with information in it. For example I have a list of titles and if I click the view link it has to give me all the information of that title.
I have managed to do half of it, I get the title and the content but not the image.
The error that I get is
Quote:A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: bras/bra_view.php
Line Number: 7
http://localhost/CodeIgniter_2.1.2/uploads/" />
and I get a broken picture
This is my controller
Code:
class Admin extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
}
function bras() {
$data['title'] = "Voluptuous Decadents";
$data['heading'] = "Bras";
$data['query'] = $this->db->get('bras');
//$this->load->view('layout');
$this->load->view('admin/bras/bras', $data);
//print_r($data);
}
function bra_view($bra_id)
{
$data['bra_item'] = $this->admin_model->get_bras($bra_id);
if (empty($data['bra_item']))
{
show_404();
}
$data['title'] = $data['bra_item']['title'];
//$this->load->view('templates/header', $data);
$this->load->view('admin/bras/bra_view', $data);
//$this->load->view('templates/footer');
}
and this is my model
Code:
class Admin_model extends CI_Model
{
public function get_bras($bra_id = FALSE)
{
if ($bra_id === FALSE)
{
$query = $this->db->get('bras');
return $query->result_array();
}
$query = $this->db->get_where('bras', array('bra_id' => $bra_id));
return $query->row_array();
}
this is my bras view
Code:
Bras view
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php //echo $heading ?></h1>
<?php echo anchor('admin/bra_create', 'Create'); ?><br />
<?php foreach($query->result() as $row): ?>
<?php echo $row->title ?><br />
<?php echo anchor("admin/bra_view/$row->bra_id", 'view');?>
<?php echo anchor("admin/update_bras/$row->bra_id", 'Update');?>
<?php echo anchor("admin/delete_bras/$row->bra_id", 'Delete');?><br />
<?php endforeach; ?>
<body>
</html>
and this is my bra_view
Code:
This is the bras view
<?php
echo '<h2>'.$bra_item['title'].'</h2>';
echo $bra_item['content'];
?>
<img src="<?php echo base_url().'uploads/'.$bra_item->filename; ?>" /><br />