Welcome Guest, Not a member yet? Register   Sign In
Problem with Undefined variable: ads_id
#1

[eluser]tuckee[/eluser]
I am very new to codeigniter. I would like to retrieve information from database. and update the status according to their ID. I manage to retrieve the information successfully, but having problem in updating it according to their ID. having this error "Undefined variable: ads_id" which I believed I have not define in the code in red. Im not really sure how to define ? could anyone help me?

My View File

<?php foreach($row as $r) :?>

<h1>&lt;?php echo $r -> ads_id; ?&gt;</h1>
<div>&lt;?php echo $r -> ads_content; echo form_dropdown('ads_status', $ads_status, 2);?&gt; </div>

&lt;?php endforeach; ?&gt;


My Controller File

function index(){
$this->load->model('admin_model');
$data['row'] = $this->admin_model->show_ads();
$this->load->view('admin_view', $data);
}

function approval()
{
extract($_POST);
$this->Admin_model->approve_ads($ads_status,$ads_id);

}

My Model File

function show_ads()
{
$query = $this->db->query('SELECT * FROM Advertisement WHERE ads_status=2');

if($query -> num_rows() > 0 )
{
foreach ($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
}

function approve_ads($status,$id)
{
$query_str = "UPDATE Advertisement SET ads_status= ? WHERE ads_id=?";
$query = $this->db->query($query_str, array($status, $id));

}




Theme © iAndrew 2016 - Forum software by © MyBB