duandui2803 2015-11-05 05:43
浏览 17

codeigniter中的意外foreach [重复]

This question already has an answer here:

hello here is my code which i have written in the codeigniter controller,when i run this code am getting Parse error: syntax error, unexpected 'foreach' (T_FOREACH) ,kindly help me on this

function send_payment_notification()
{
    if($_POST)
    {

     $vendor_id=$_POST['vendor_id'];
     $vendor_name=$_POST['vendor_name'];
     $from_date=$_POST['from_date'];
     $to_date=$_POST['to_date'];

     for($i=0;$i<count($vendor_id);$i++)
     {
        $v_id= $vendor_id[$i];
        $v_name= $vendor_name[$i];
        $f_date=$from_date[$i];
        $t_date=$to_date[$i];

        $query="select * from `order` where (DATE(order.service_date) between '".$f_date."' and '".$t_date."') AND status_code='OCMP' and order.vendor_id=$v_id";
        $data['order_ids']=$this->finance_model->run_manual_query_return_result2($query);


        $query="SELECT v.vendor_email,c.cat_name,c.commission_type,c.commission,sum(c.commission) commissionrupees, SUM( CASE WHEN final_amount_paid !=0 THEN final_amount_paid ELSE total_cost END ) AS total,order.vendor_id,v.vendor_name,sum(distinct v.wallet_balance) as wallet FROM `order` join vendor v on v.vendor_id=order.vendor_id join category c on c.cat_id=v.cat_id where (DATE(order.service_date) between '".$f_date."' and '".$t_date."') AND status_code='OCMP' and order.vendor_id=$v_id";
    $payment_notification=$this->finance_model->run_manual_query_return_row($query);


         $template="

        Hi Service Providers,

        Please find payment details for the week ".$f_date." to ".$t_date." .

        <table>
            <tr> <th>Category </th><th>order ids </th><th>Total Amount </th> <th>Commission charged </th><th>online payment </th><th>Bro4u offers </th><th>Total payable </th> </tr>

    <tr> 
    <td>".$payment_notification->cat_name."</td> 

    <td>"foreach($data['order_ids'] as $o_id)
     { 
     $o_id->order_id

     }"</td> 

    <td>".$payment_notification->total."</td> 

    <td>".$payment_notification->commissionrupees."</td> 

    <td>online</td> 

    <td>offers</td> 

    <td>payable</td>
      </tr>     


        </table>

        <br/>   
        Happy to serve,<br/>
        Team Bro4u<br/>
        ";










        //$this->bro4u->email_alert($payment_notification->vendor_email, "credit of amount", $template);


    echo $template;


     }  

    }




}
</div>
  • 写回答

4条回答 默认 最新

  • drktvjp713333 2015-11-05 05:45
    关注

    Need to close statement:

    Change:

    <td>"foreach($data['order_ids'] as $o_id)
    

    To:

    <td>";foreach($data['order_ids'] as $o_id)
    
    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条