insert month codeigniter and jquery (beginner learner) -
problem when insert month..on segment show 01,02,03 when insert database show 1,2,3,4
how set 01,02,03
view code
$.post("<?php echo base_url('account/save'); ?>", { new_sum:$("#test<?php echo $row['br_loc'];?>").val(), status:$("#status<?php echo $row['br_loc'];?>").val(), sum:$("#sum<?php echo $row['br_loc'];?>").html(), year:<?php echo $this->uri->segment(4)?>, month:<?php echo $this->uri->segment(3)?> }, function(data) { }); });
controller
public function save() { $data = array('date_send'=>date("y-m-d"), 'ac_month'=>$this->input->post('month'), 'usr_approve'=>$this->session->userdata('username'), 'status'=>$this->input->post('status'), 'new_sum'=>$this->input->post('new_sum'), 'ac_year'=>$this->input->post('year')); $this->db->insert('account',$data); }
if ac_month
column type int cannot keep leading zeros.
i go string varchar
type or store month integer when retrieving data either inject leading zeros or use lpad in sql query.
select lpad(ac_month,4,0) month table
Comments
Post a Comment