2011-07-26 2 views
-2
for ($x = 1; $x <= $num; $x++) { 
$userArray[] = $this->input->post("select" . $x . ""); 
} 
    $userArray = split(',', $userArray); 
$productName = $userArray[0]; 
$barcode = $userArray[1]; 
$quantity = $userArray[2]; 
    $flag = $this->cartmodel->productCategory($category); 
} 

코드의 가장 큰 문제는 배열 ....메시지가 : 오프셋 정의되지 않은 : 분할 기능과 값을 배열로 설정

로 걸립니다 ... $ userArray에 올 수없는 것입니다

텍스트 상자를 통해 수량을 가져 오는 해요 .... 의심을 가지고 ..하지만

<input type="text" name ="Quantity<?=$i;?>" id = "Quantity<?=$i;?>" value=""/></td> 
    <select name="select<?=$i;?>"><option value="">NO</option><option value="<?=$row ->product_name;?>,<?=$row->barcode?>,<?=$i;?>">YES</option> 
+0

폭발 또한 예상됩니다. –

답변

1

http://php.net/manual/en/function.split.php .... 배열에 얻을 수 없습니다 - 분할 인수로 문자열을 사용하지 배열.

for ($x = 1; $x <= $num; $x++) 
{ 
    $input = $this->input->post("select" . $x . ""); 
    $row = split(',', $input); 
    $productName = (isset($row[0]) ? $row[0] : ''); 
    $barcode = (isset($row[1]) ? $row[1] : ''); 
    $quantity = $this->input->post("quantity" . $x . ""); 
    $flag = $this->cartmodel->productCategory($category); 
} 
+0

메시지 : foreach()에 대해 잘못된 인수 제공 – user855492

+0

수정 사항을 참조하십시오. – bigstylee

+0

메시지 : 정의되지 않은 오프셋 : $ barcode = $ row [1]; – user855492

관련 문제