2017-07-25 116 views
0

如何在tpl文件中打印记录数组? 这是我的PHP代码:如何在smarty中打印tpl文件中的记录?

$inbox=mysql_query("SELECT * FROM table1"); 
    $inbox_rec=array(); 
    while($inbox_data=mysql_fetch_assoc($inbox)) 
    { 
     $sent_mail_id = 12; 
     array_push($inbox_rec,$inbox_data); 
     $send=mysql_query("SELECT * FROM table2 where id = '$sent_mail_id'"); 
     $i=0; 
     while($send_data=mysql_fetch_assoc($send)) 
     { 
     array_push($inbox_rec[$i],$send_data); 
     } 
     $i++; 

    } 
    $smarty->assign(array("inbox_rec"=>$inbox_rec)); 

我要查看在第三方物流文件中的记录,因为我已经使用在TPL文件中的代码,如下所示:

{foreach $inbox_rec as $value} 
      <table class="table table-responsive"> 
      <tbody> 
       <tr> 
       <td align="left"> 
       <h5 style="color:#426AD5;"><b>{$value.mail_name}</b></h5> 
       <h5 style="color:#426AD5;"><b>{$value.mail_email}</b></h5> 
       <h5 style="color:#595959;"><b>{$value.mail_msg}</b></h5><br /> 
       {foreach inbox_rec as $detail} 

       <h5 style="color:#426AD5;"><b>Admin</b></h5> 
       <h5 style="color:#595959;"><b>{$detail[$i].sent_mail_msg}</b></h5><br /> 

       {/foreach} 
{/foreach} 

回答

1

可以打印记录在您的tpl文件:

{$inbox_rec|@print_r}