Welcome Guest, Not a member yet? Register   Sign In
checkbox = checked then enter = 1 otherwise value insert = 0
#1

[eluser]Rocky Mehta[/eluser]
My database field : 'free'=>'tinyint' bydefalult = 0
model page:
Code:
function insert_facility($filename)
{
$this->load->database();
$data = array(
  'venue_facilities_name' => $this->input->post('venue_facilities_name'),
  'venue_facilities_image'=> $filename,
  'free'    => $this->input->post('free'),
  'charg'   => $this->input->post('charg'),
  'bring'   => $this->input->post('bring')
  );
$this->db->insert('venue_facilities', $data);
}
function general()
{
$data['mvenue_facilities_id']['value'] = 0;
$data['venue_facilities_name'] = array('name'=>'venue_facilities_name','style'=>'width:250px');
$data['venue_facilities_image'] = array('name'=>'venue_facilities_image');
$data['free']   = array('name'=>'free','checked'=>TRUE);
$data['charg']   = array('name'=>'charg','checked'=>false);
$data['bring']   = array('name'=>'bring','checked'=>false);

return $data;
}
Controller page:
Code:
if ($this->input->post('save'))
{
if ($this->input->post('venue_facilities_id'))
{
  $this->venue_facilities_model->do_upload();
  $this->venue_facilities_model->update_facility($_FILES['userfile']['name']);
  echo "Data Updated Successfully";        redirect('http://localhost/venue/index.php/venue_facilities/update/');
}
else
{
  $this->venue_facilities_model->do_upload();
  $this->venue_facilities_model->insert_facility($_FILES['userfile']['name']);
         echo "Data Inserted Successfully";
}
}
i am insert the data the checkbox is not checked then enter bydefault = 0 but if i check the checkbox its also enter 0
can any one help how can i do the if check box is checked then enter in database value = 1.


Messages In This Thread
checkbox = checked then enter = 1 otherwise value insert = 0 - by El Forum - 02-25-2012, 06:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB