dongyanghan0556 2019-02-27 01:37
浏览 10

Codeigniter中的数组

I had simple key in the totalwithouttax with 3000, totaltax with 10 and totalamtincltax with 2000 in my interface. And I had echo the array, the totaltax and totalamtincltax echo the right value that I key in, But totalwithouttax echo 1000 only and data inserted in database is 1.000000.

Please help me. Thank You.

Controller:

    $custTd = $post['id'];
    $custMame = $post['name'];
    $custEmail = $post['email'];
    $custAddr = $post['address'];;
    $custTel = $post['telno'];
    $remarks = $post['remark'];
    $paymentOption = $post['options'];
    $promoCode = $post['promo_code'];

    $arraySize = count($post['totalwithouttax']);
    for($i=0; $i<$arraySize; $i++){

    $totalWithoutTax = $post['totalwithouttax'][$i]; //$post['totalwithouttax'];
    $totalTax = $post['totaltax'][$i]; //$post['totaltax'];
    $totalAmtInclTax = $post['totalamtincltax'][$i];//$post['totalamtincltax'];

    //MASSAGE DATA TO BE INSERTED TO ARRAY
    $orderHeader = array(
                                    'user_id' =>  $custTd,
                                    'status' =>  1,
                                    'cust_name' =>  $custMame,
                                    'cust_email' =>  $custEmail,
                                    'cust_addr' =>  $custAddr,
                                    'cust_tel' =>  $custTel,
                                    'remarks' =>  $remarks,
                                    'pay_option' =>  $paymentOption,

                                    'total_without_tax' =>  $totalWithoutTax,
                                    'total_tax' =>  $totalTax,                              'total_amt_incl_tax' =>  $totalAmtInclTax,
                                    'epp_first_payment' =>  $eppFirstPayment,

                                  );

    //INSERT ORDER HEADER
    $orderHeaderId = $this->order->InsertOrderHeader($orderHeader);

view:

<tr class="item-details">
                        <td><span class="rowNumber">1</span></td>
                         <td class="">
                        <?php
                        $options = array(
                                         '' => '~Choose An Item~'
                                         );
                        foreach ($item as $rows){
                            $options[$rows->id] = $rows->item_name;
                        }

                        $select = array(

                                        'id' => 'item_id',
                                        'class' => 'form-control'
                                        );
                        echo form_dropdown('item_id[]', $options,set_value('item_name'),$select);
                        ?>
                        </td>
                        <td class=""><input type="number" class="item-qty" name="qty[]" min="0.00" /></td>
                        <td><input type="number" name="weight[]" class="weight" step="any" /></td>
            <td><input type="number" name="transportation[]" class="transporation" step="any" /></td>
            <td><input type="text" id="gp[]" name="gp[]" value="" /></td>
                        <td><input type="text" id="discount[]" name="discount[]" value=""/></td>
                        <td><input type="text" id="unit_price[]" name="unit_price[]" value="" /></td>
                        <td align="right">
            <input type="text" id="totalwithouttax" name="totalwithouttax[]" value="">
            </td>
            <td align="right">
            <input type="text" id="totaltax" name="totaltax[]" value="">
            </td>
            <td align="right">
            <input type="text" id="totalamtincltax" name="totalamtincltax[]" value="">
            </td>
                     </tr><br/>
  • 写回答

1条回答 默认 最新

  • douke6857 2019-02-27 01:42
    关注

    You are wrong way calling post method

        $custTd = $_POST['id'];
        $custMame = $_POST['name'];
        $custEmail = $_POST['email'];
        $custAddr = $_POST['address'];;
        $custTel = $_POST['telno'];
        $remarks = $_POST['remark'];
        $paymentOption = $_POST['options'];
        $promoCode = $_POST['promo_code'];
    
        $arraySize = count($post['totalwithouttax']);
     for($i=0; $i<=$arraySize; $i++){
    
    $totalWithoutTax = $_POST['totalwithouttax'][$i];
    $totalTax = $_POST['totaltax'][$i]; //$post['totaltax'];
    $totalAmtInclTax = $_POST['totalamtincltax'][$i];
    
    //MASSAGE DATA TO BE INSERTED TO ARRAY
    $orderHeader = array(
    
                                'user_id' =>  $custTd,
                                'status' =>  1,
                                'cust_name' =>  $custMame,
                                'cust_email' =>  $custEmail,
                                'cust_addr' =>  $custAddr,
                                'cust_tel' =>  $custTel,
                                'remarks' =>  $remarks,
                                'pay_option' =>  $paymentOption,
    
                                'total_without_tax' =>  $totalWithoutTax,
                                'total_tax' =>  $totalTax,                              
                                 'total_amt_incl_tax' =>  $totalAmtInclTax,
                                'epp_first_payment' =>  $eppFirstPayment,
    
                              );
    

    }

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线