如何使用for循环从mpdf PHP中的数组中打印值

问题描述 投票:0回答:1

我正在使用MPDF库来生成pdf文件表单数据库。

我想在MPDF中使用带有for循环的数组在html表TD中显示数据库中的whatsapp号。

这是我尝试的代码,但是它无法显示任何值。

请帮助我找出问题并能够使用for循环显示记录

       $query = "SELECT * from  social_messaging_app  where User_Id = '$split_ids[0]' and Request_Id='$split_ids[1]'  and Social_Messaging_App_Name LIKE 'Wh%' ORDER BY Social_Messaging_App_Id DESC";

                            $res_cus = mysqli_query($connection, $query);
                            $total_rec_whatsaap = mysqli_num_rows($res_cus);
                            $whatsapp_accounts = array();
                            $whatsapp_id = 1;
                            while ($row = mysqli_fetch_array($res_cus)) {
                                $whatsapp_accounts[$whatsapp_id] = $row['Social_Messaging_App_No'];
                                $whatsapp_id++;

                            }
        $html="";
        if($total_rec_whatsaap>0){
    $html .= ' 
                    <table style="width: 100%">
                    <tbody>
                        <tr>

                            <td style="width: 5%;font-size:14px;"></td>
                            <td style="width: 25%;font-size:14px;">Whatsapp Address(es)</td>
                        <td style="width: 70%; border-bottom: 1px solid black;text-align: left;font-size:14px;">';
                                    for($i = 1; $i <= $total_rec_whatsaap; $i++)
                                    {

                                     strtoupper($whatsapp_accounts[$i]);
                                    }

     $html .= '      
                            </td>
                        </tr>


                    </tbody>
                </table> ';
}

[请协助我在td中打印值。使用下面的代码,它给我空的行。

php html mpdf
1个回答
2
投票

您错过了在for循环中串联字符串的方法

© www.soinside.com 2019 - 2024. All rights reserved.