i want to search coupon number in a row if coupon number is match given by user get all values in this single row using Codeigniter. Here is My Code.
Model
public function ven_coupon($coupon)
{
$where = array(
'number' => $coupon,
);
$this->db->select()
->from('vendor_coupons')
->where($where);
$data = $this->db->get();
return $data->result_array();
}
Controller
public function ven_coupon()
{
$this->load->model('front');
if ($_POST) {
$number = $_POST['coupon'];
if (!$this->front->ven_coupon($number)) {
echo "Not Valid";
}
$payment = $this->cart->total();
$discount['discount'] = ($payment*10)/100;
$this->load->view('checkout',$discount);
}
}
View
<form action="<?=base_url();?>home/ven_coupon" method="post">
Coupon Number: <input type="text" name="coupon">
<input type="submit" name="submit" value="Apply Coupon">
</form>