Jack Johnson Jack Johnson - 3 months ago 22
MySQL Question

Update table data within Codeigniter Controller / MySQL

I'm in a small pickle on this one. I'm using Codeigniter controller.

I need to update an Order status where "DATA HERE" is located in the code below.

Basically here is what i need to do locate the $orderid within a table called "orders" find the "status" and update it to the text "Paid".

$orderid = $id;

if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
{
// DATA HERE
}


Any help is greatly appreciated.

Here is my current code

$updateData=array("status"=>"Paid");

if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
{

$d = $this->db->get('offers_orders');
$this->db->select('status');
$this->db->where('order_number', $id);

$orderdata = $d->result_array();

$this->db->update("offers_orders", $updateData);

}

Answer

Assuming you have established your database connection.

 $orderid = $id;

if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
{

$updateData=array("status"=>"Paid");

$this->db->where("orderid",$orderid);
$this->db->update("orders",$updateData);    
}