2017-07-16 12 views
0

私はcodeiginterカートを使用しています。イムcodeigniterコントローラのAjax出力応答

  1. Parse error: syntax error, unexpected T_IF Line Number: 873
  2. Message: syntax error, unexpected 'form_hidden' (T_STRING)
$output = ''; 
      if(count($cart) == 0) 
      { 
      $output .= ' <tr> 
        <td colspan="8"> 
         <div class="noitemcontent alert-dismissible alert-info">' 
         . $this->lang->line('sales_no_items_in_cart'). 
        '</div> 
        </td> 
       </tr>'; 
       } else // 
      { 
       foreach(array_reverse($cart, true) as $line=>$item) 
       { 
        form_open($controller_name."/edit_item/$line", array('class'=>'form-horizontal line-item', 'id'=>'cart_'.$line)) . 
       '<tr> 
          <td> ' 
          . anchor($controller_name."/delete_item/$line", '<span class="glyphicon glyphicon-trash"></span>') . 
          '</td> 
          <td style="align: center;"> '. 
           $item['name'] .' 

          </td>'; 
          if ($items_module_allowed) 
          {     
       $output .= '<td> '. 
        form_input(array 
        ('name'=>'price', 'class'=>'form-control input-sm cartline', 'value'=>to_currency_no_money($item['price']), 
        'tabindex'=>++$tabindex, 
        'data-form' => $line 
        )) .' 
      </td>';   } 
          else 
          { 
          $output .= ' <td> '. 
             to_currency($item['price']). 
             form_hidden('price', $item['price']) 
           . '</td> '; 
          } 
         $output .= ' <td>'. 
           if($item['is_serialized']==1) //error Type: ParseError Message: syntax error, unexpected 'if' (T_IF) 
           { 
            to_quantity_decimals($item['quantity']) 
            form_hidden('quantity', $item['quantity']) //Message: syntax error, unexpected 'form_hidden' (T_STRING) 
           } 
           else 
           {        
         form_input(array('name'=>'quantity', 
         'id','quantity', 
         'type'=>'number', 
         'class'=>'form-control input-sm cartline', 
          'value'=>to_quantity_decimals($item['quantity']), 
          'tabindex'=>++$tabindex, 
          'data-form' => $line)); 
           }.' 
           </td><td>'; 
    form_input(array('name'=>'discount', 
     'value'=>$item['discount'], 
     //'type'=>'number', 
     // 'min'=>0, 
     // 'max'=>100, 
     'title'=>'Discount (5 or 5%)', 
     'tabindex'=>++$tabindex, 
     'class'=>'form-control input-sm cartline', 
     'data-form' => $line)) 

    $output .= '</td></tr><tr>'. 
          if($item['allow_alt_description']==1) 
          { 
          .'<td style="color: #2F4F4F;"> '. 
           $this->lang->line('sales_description_abbrv') .'</td>'. 
          }.' 
          <td colspan="2" style="text-align: left;">'. 
           if($item['allow_alt_description']==1) //error 
           { 
            echo form_input(array('name'=>'description', 'class'=>'form-control input-sm', 'value'=>$item['description'])) 
           } 
           else 
           { 
            if ($item['description']!='') 
            { 
             echo $item['description']; 
             echo form_hidden('description', $item['description']) 
            } 
            else 
            { 
             $this->lang->line('sales_no_description') 
             form_hidden('description','') 
            } 
           } 
           .' 
          </td> 
          <td>&nbsp;</td> 
          <td style="color: #2F4F4F;">'. 
           if($item['is_serialized']==1) 
           { 
            $this->lang->line('sales_serial') 
           }. 
          '</td> 
          <td colspan="4" style="text-align: left;">'. 
           if($item['is_serialized']==1) 
           { 
            form_input(array('name'=>'serialnumber', 'class'=>'form-control input-sm', 'value'=>$item['serialnumber'])) 
           } 
           else 
           { 
            form_hidden('serialnumber', '') 
           } 
           .' 
          </td> 
         </tr>'; 
        form_close()      
       } 
      } 
      echo $output; 

答えて

0

に感謝あなたが行を分割する;を逃した私は、構文エラーのヘルプを与える理由を私は知らないAjaxリクエストを通じてなく、私に多くのエラーを与えて応答出力にカートのデータを送信します。または、後で数行を実行しているときにこれらの行を連結したい場合は、.を入力します。

さらに、文字列とif文を(直接ではなく)連結することはできません。予期せぬif文がある場所の前にドットをセミコロンで置き換えます。