dpcwz210393 2016-09-16 00:52
浏览 27

创建html表php

Hi guys I'm quite new in php. I want to create a string of html table to later use it mpdf but in the course of constructing my table the code seems ok but no html table with data generated just the header.

Below is my code:

 $html ='<div class="row">
                <div class="col-lg-12">
                 <table  width="100%" class="table table-striped table bordered">
                    <thead>
                    <tr>
                    <th class="text-left">Code</th>
                    <th class="text-left">Phone Number</th>
                    <th class="text-left">Delivery Date</th>
                    <th class="text-left">Amount HT</th>
                    <th class="text-left">Amount TVA</th>
                    <th class="text-left">Amount TTC</th>
                    <th class="text-left">Payment Mode</th>
                </tr>
                </thead >
                <tbody>';
                    foreach($estimateArray as $item):
                        if(($startDate <= date_create($item->created) && date_create($item->created) <= $endDate)){
                            $html .=  ' <tr>
                            <td class="text-left">'; echo $item->customer_name;'</td>
                            <td class="text-left">'; echo $item->document_number;'</td>
                            <td class="text-left">'; echo $item->delivery_date;'</td>
                            <td class="text-left">'; echo $item->amount_ht;'</td>
                            <td class="text-left">'; echo $item->amount_tva;'</td>
                            <td class="text-left">'; echo $item->amount_ttc;'</td>
                            <td class="text-left">'; echo $item->payment_mode;'</td>
                        </tr>';

                        } endforeach;
                        $html .= '
                                    </tbody>
                                </table>
                            </div>
                     </div>
        ';

Please I need help.

  • 写回答

4条回答 默认 最新

  • douzhuanfen5923 2016-09-16 00:56
    关注

    You are using echo instead of appending property value to $html variable.

    Try something like:

    <td class="text-left">' . $item->customer_name . '</td>
    

    Edit: It's much more clearer using variables in string this way:

    $output = "<td class=\"text-left\">{$item->customer_name}</td>";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制