数据未添加到数据库



一直在尝试解决我的代码的问题。很久没有编程点火器了。当我单击"添加项目"按钮时,它只是停留在同一页面上,没有任何反应。这是我的观点和模型函数:

视图:

<form action="<?php echo base_url().'item/addItem' ?> " method="post">
<div class="form-group">
<label>Name of Patient</label>
<input type="name" class="form-control" name="patient_name" placeholder="Name Here" value="<?php echo set_value('patient_name'); ?>">
</div>
<div class="form-group">
<label>Age</label>
<input type="input" class="form-control" name="age" placeholder="Age Here" value="<?php echo set_value('age'); ?>">
</div>
<div class="form-group">
<label>Date</label>
<input type="date" class="form-control" name="date" placeholder="Date" value="<?php echo set_value('date'); ?>">
</div>
<div class="form-group">
<label>Grade/PD</label>
<input type="input" class="form-control" name="grade" placeholder="Grade/PD Here" value="<?php echo set_value('grade'); ?>">
</div>
<div class="form-group">
<label>Frame No.</label>
<input type="input" class="form-control" name="frame_no" placeholder="Frame No. Here" value="<?php echo set_value('frame_no'); ?>">
</div>
<div class="form-group">
<label>Frame Amount</label>
<input type="input" class="form-control" name="frame_amo" placeholder="Frame Amount Here" value="<?php echo set_value('frame_amo'); ?>">
</div>
<div class="form-group">
<label>Lens Type/Amount</label>
<input type="input" class="form-control" name="lens_typeamo" placeholder="Lens Type/Amount Here" value="<?php echo set_value('lens_typeamo'); ?>">
</div>
<div class="form-group">
<label>Laboratory</label>
<input type="input" class="form-control" name="labo" placeholder="Laboratory Here" value="<?php echo set_value('labo'); ?>">
</div>
<div class="form-group">
<label>Total Amount</label>
<input type="input" class="form-control" name="total" placeholder="Total Amount Here" value="<?php echo set_value('total'); ?>">
</div>
<div class="form-group">
<label>Saleslady</label>
<input type="input" class="form-control" name="saleslady" placeholder="Saleslady Name Here" value="<?php echo set_value('saleslady'); ?>">
</div>
<div class="form-group">
<label>Doctor</label>
<input type="input" class="form-control" name="doctor" placeholder="Doctor Name Here" value="<?php echo set_value('doctor'); ?>">
</div>

<a href="<?php echo base_url().'item/itemlistadmin'?>" class="btn btn-info " role="button"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> BACK </a>
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ADD ITEM</button>
</form>

我不确定我在这个区域输入的内容是否正确:C

型:

public function addItem(){
$patient_name = $this->input->post('patient_name');
$age = $this->input->post('age');
$date = $this->input->post('date');
$grade = $this->input->post('grade');
$frame_no = $this->input->post('frame_no');
$frame_amo = $this->input->post('frame_amo');
$lens_typeamo = $this->input->post('lens_typeamo');
$labo = $this->input->post('labo');
$total = $this->input->post('total');                       
$saleslady = $this->input->post('saleslady');
$doctor = $this->input->post('doctor'); 

$item = array(
'px_name' => $patient_name,
'px_age' => $age,
'px_date' => $date,
'px_grade' => $grade,
'px_frame_no' => $frame_no,
'px_frame_amo' => $frame_amo,
'px_lens_typeamo' => $lens_typeamo,
'px_labo' => $labo,
'px_total' => $total,
'px_saleslady' => $saleslady,
'px_doctor' => $doctor
);
$this->db->insert('tblitem',$item);
}

这是我的数据库:

看这里 不知道要改变什么了:'<请帮忙。谢谢!>

应该是

控制器:

public function addItem() {
$patient_name = $this->input->post('patient_name');
$age = $this->input->post('age');
$date = $this->input->post('date');
$grade = $this->input->post('grade');
$frame_no = $this->input->post('frame_no');
$frame_amo = $this->input->post('frame_amo');
$lens_typeamo = $this->input->post('lens_typeamo');
$labo = $this->input->post('labo');
$total = $this->input->post('total');
$saleslady = $this->input->post('saleslady');
$doctor = $this->input->post('doctor');
$item = array(
'px_name' => $patient_name,
'px_age' => $age,
'px_date' => $date,
'px_grade' => $grade,
'px_frame_no' => $frame_no,
'px_frame_amo' => $frame_amo,
'px_lens_typeamo' => $lens_typeamo,
'px_labo' => $labo,
'px_total' => $total,
'px_saleslady' => $saleslady,
'px_doctor' => $doctor
);
$this->db->insert($item);
}

型:

public function insert($item)
{
$this->db->insert('tblitem', $data);
}

试试这个:

控制器

public function addItem()
{
$item=array(  
'patient_name' = $this->input->post('patient_name'),
'age' = $this->input->post('age'),
'date' = $this->input->post('date'),
'grade' = $this->input->post('grade'),
'frame_no' = $this->input->post('frame_no'),
'frame_amo' = $this->input->post('frame_amo'),
'lens_typeamo' = $this->input->post('lens_typeamo'),
'labo' = $this->input->post('labo'),
'total' = $this->input->post('total'),
'saleslady' = $this->input->post('saleslady'),
'doctor' = $this->input->post('doctor'),     
);
$this->ModelName->addItem($item); 
}

public function addItem($item)
{  
$this->db->insert('tblitem', $item);
$this->db->update('users');
}

控制器的代码:
公共函数add_item((

{

$data=数组(

'patient_name' = $this->input->post('patient_name'(,

'age' = $this->input->post('age'(,

'date' = $this->input->post('date'(,

'grade' = $this->input->post('grade'(,

'frame_no' = $this->input->post('frame_no'(,

'frame_amo' = $this->input->post('frame_amo'(,

'lens_typeamo' = $this->input->post('lens_typeamo'(,

'labo' = $this->input->post('labo'(,

'total' = $this->input->post('total'(,

'saleslady' = $this->input->post('saleslady'(,

'doctor' = $this->input->post('doctor'(,

(;

$this>加载>模型('model_name'(;

$this->model_name->add_item($data(;

}

model's code :
public function add_item($data){

$this->db->insert('table_name',$data(;

}

不要忘记检查.htaccess文件并base_url

相关内容

  • 没有找到相关文章

最新更新