I have a project on inventory system. a user can pay for an order step by step if they can't offer the whole payment at once. for eg. if a user wants to buy Laptop, and the price is $1000, they can pay 300 on their first payment, $500 in second round, and $200 in third round. I tried it by inserting the value as an array in mysql database, i updated the payment after i write some code. the code is.
i am using codeigniter
VIEW
MODEL public function getPreviousPayment($id) {
$sql = "SELECT paymentA FROM orders WHERE id = ?";
$query = $this->db->query($sql, array($id));
return $query->result_array();
}
CONTROLLER
public function payment($id) {
$paymentA[] = $this->model_orders->getPreviousPayment($id);
$paymentN = $this->input->post('paymentNext');
$paymentNArray = [$paymentN];
$newArr = array_merge($paymentA ,$paymentNArray);
$data = array(
'paymentA' => json_encode($newArr),
);
}
what i get is ... look at the screen shot below my fetched table when nothing is pad