This is the table for requests
https://i.sstatic.net/NWT4y.png
How can I update the ticket_status field with a value of "2" if at least one of the requests has is_approved=1, based on the orderid?
I have attempted the following code, but it is not updating all the ticket statuses for the respective orderids:
Controller Code:
function pend_request($orderid){
$this->load->model('request');
$this->session->set_flashdata('message', 'Order successfully pended');
$this->request->pend_request($orederid);
redirect('admin/Requests', 'refresh');
}
Model Code:
function pend_request($orderid)
{
$this->db->set('ticket_status', "2");
$this->db->where('orderid', $orderid);
$this->db->update('requests');
}
View Code:
<?php
foreach($requests as $request):
endforeach;
if($request->is_approved == 1){?>
<li>
<a href="<?php echo base_url('admin/requests/pend_request/'.$request->orderid); ?>" class="btn btn-xs btn-warning"><span class="icon-minus" style="color:blue"></span> Pend</a>
</li>
<?php }
else{}
?>