简体   繁体   English

如何在smarty中打印tpl文件中的记录?

[英]how to print records in tpl file in smarty?

How to print the records array in the tpl file? 如何在tpl文件中打印记录数组? This is my php code: 这是我的PHP代码:

$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));

I want to view the records in tpl file as I have used the code in tpl file as shown below: 我想查看tpl文件中的记录,因为我已经使用了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}

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

{$inbox_rec|@print_r}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM