[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>
<?php echo $r -> ads_id; ?></h1>
<div><?php echo $r -> ads_content; echo form_dropdown('ads_status', $ads_status, 2);?> </div>
<?php endforeach; ?>
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));
}