[eluser]bianchi[/eluser]
Hello everyone...
Can you tell me why I can't insert data into my table ?
Thx
The controller :
============
function adddisplay(){
// set common properties
$data['title'] = 'Add new display';
$data['action'] = site_url('display/adddisplay');
$data['link_back'] = anchor('display/index/','Back to list of displays',array('class'=>'back'));
// set validation properties
$this->_set_fields();
$this->_set_rules();
// run validation
if ($this->validation->run() == FALSE){
$data['message'] = '';
}else{
// save data
$display = array(
'schedule' => datetime('YYYY-mm-dd 24h', strtodatetime($this->input->post('schedule'))),
'airline' => $this->input->post('airline'),
'flight' => $this->input->post('flight'),
'city' => $this->input->post('city'),
'via' => $this->input->post('via'),
'gate' => $this->input->post('gate'),
'counter' => $this->input->post('counter'));
$id = $this->displayModel->save($display);
// set form input name="id"
$this->validation->id = $id;
// set user message
$data['message'] = '<div class="success">add new display success</div>';
}
// load view
$this->load->view('displayEdit', $data);
}
===========
model :
===========
function save($display){
$this->db->insert($this->tbl_Display, $display);
return $this->db->insert_id();
}
==========
view
==============
<form method="post" action="<?php echo $action; ?>">
<div class="data">
<table>
<tr>
<td width="30%">ID</td>
<td><input type="text" name="id" disabled="disable" class="text" value="<?php echo $this->validation->id; ?>"/></td>
<input type="hidden" name="id" value="<?php echo $this->validation->id; ?>"/>
</tr>
<tr>
<td valign="top">Schedule<span style="color:red;">*</span></td>
<td><input type="text" id="schedule" class="text" value="<?php echo $this->validation->schedule; ?>"/>
<?php echo $this->validation->schedule_error; ?>
<a href="[removed]NewCssCal('schedule','yyyymmdd','dropdown',true,24,false)"><img src="<?php echo base_url(); ?>style/images/calendar.png" alt="calendar" border="0"></a>
</td>
</tr>
<tr>
<td valign="top">Airline<span style="color:red;">*</span></td>
<td><input type="text" name="airline" class="text" value="<?php echo $this->validation->airline; ?>"/>
<?php echo $this->validation->airline_error; ?></td>
</tr>
<tr>
<td valign="top">Flight<span style="color:red;">*</span></td>
<td><input type="text" name="flight" class="text" value="<?php echo $this->validation->flight; ?>"/>
<?php echo $this->validation->flight_error; ?></td>
</tr>
<tr>
<td valign="top">City<span style="color:red;">*</span></td>
<td><input type="text" name="city" class="text" value="<?php echo $this->validation->city; ?>"/>
<?php echo $this->validation->city_error; ?></td>
</tr>
<tr>
<td valign="top">Via<span style="color:red;">*</span></td>
<td><input type="text" name="via" class="text" value="<?php echo $this->validation->via; ?>"/>
<?php echo $this->validation->via_error; ?></td>
</tr>
<tr>
<td valign="top">Gate<span style="color:red;">*</span></td>
<td><input type="text" name="gate" class="text" value="<?php echo $this->validation->gate; ?>"/>
<?php echo $this->validation->gate_error; ?></td>
</tr>
<tr>
<td valign="top">Counter<span style="color:red;">*</span></td>
<td><input type="text" name="counter" class="text" value="<?php echo $this->validation->counter; ?>"/>
<?php echo $this->validation->counter_error; ?></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Save"/></td>
</tr>
</table>
</div>
</form>
===================