내 모델은 DB에 삽입 배열입니다. 또한보기 파일 예제를 제출했습니다. 루프와 함께 codeigniter에 배치 데이터를 삽입하는 것을 도와주세요.codeigniter에 배열 삽입 오류가 발생했습니다.
class Purchase_model extends CI_Model{
public function purchase(){
$price = $this->input->post('price');
$quantity = $this->input->post('quantity');
$date = $this->input->post('date');
$vendor_name = $this->input->post('vendor_name');
$model = $this->input->post('model');
$invoice_no = $this->input->post('invoice');
$temp = count($this->input->post('vendor_name'));
for($i=0; $i<$temp; $i++){
$data = array(
'date'=>$date[$i],
'vendor_name'=>$vendor_name[$i],
'model'=>$model[$i],
'price' =>$price[$i],
'purchase_quantity'=>$quantity[$i],
'amount' =>$price[$i]*$quantity[$i],
'invoice_no'=>$invoice_no[$i]
);
$insert = $this->db->insert('purchase',$data);
return $insert; }
}
하지만 내가
Sl date Vendor name model price quantity amount invoice
89 2 A 1 0 0 a
이 도와주세요 DB에 다음과 같은 가치를 제출할 때. DB에 하나의 양식이있는 다중 값 삽입이 필요합니다.
같은 내보기 양식의보기는<?php
$data = array ('name' => 'quantity',
'class' =>'input-xlarge',
'value' => set_value('quantity')
);
?>
<?php echo form_input ($data); ?>
내 컨트롤러는
public function purchase()
{
if($this->Purchase_model->purchase()){
$this->session->set_flashdata('Success', 'You are entered data successfully');
redirect('home/purchase_form');
}
}
컨트롤러 코드 가능한 경우를 보여주십시오 .. –
공공 기능 구입() { \t \t \t if ($ this-> Purchase_model-> purchase()) { \t \t \t \t \t $ this-> session-> set_flashdata ('성공', '데이터를 성공적으로 입력했습니다'); \t \t \t \t \t redirect ('home/purchase_form'); \t \t \t \t } – user3752230
질문을 편집하고 전체보기 코드를 표시하면 표시된 단일 요소 일뿐입니다. –