【问题标题】:MySQL result outputs the string six times (using Smarty)MySQL结果输出字符串六次(使用Smarty)
【发布时间】:2015-07-26 19:27:53
【问题描述】:

我目前正在使用 Smarty 与 PHP 集成,我正在分配一个数组,我在 Smarty 的 html 页面中使用该数组:

ma​​in.php

$sa = array();
$query = mysqli_query($link, "SELECT * FROM `content`");
while($row = mysqli_fetch_array($query))
{
    $sa = $row;
}

$template->assign('content', $sa);

ma​​in.html

    {section name=nr loop=$content}
    {$content.text}
    {/section}

文本表中的字段等于“d”

输出是“d d d d d d”

不胜感激,谢谢!

【问题讨论】:

  • content 表是什么样的?
  • ID (int 11) (主键) (AUTO_INCREMENT) 标题 (varchar 500) (latin1_swedish_ci) 文本 (varchar 5000) (latin1_swedish_ci)

标签: php arrays mysqli smarty smarty3


【解决方案1】:

设法找到解决方案,我已删除 {section} 并改为这样做,因为我之前分配了数组:

{$con.text}

不把它放在 {section} 标签中

希望这对将来的任何人都有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-15
    • 1970-01-01
    • 2020-03-25
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    相关资源
    最近更新 更多