0

我有 3 个表,我在 while 循环中查询了两个表和第二个表,这个表是结果视图中的问题,请检查附件以了解问题,这是 php 代码:

       $select_all =  mysql_query("SELECT categories.id,cat![enter image description here][1]egories.name,categories.name_en,
categories.block_type,group_fields.ct_id,group_fields.content,group_fields.content_en
 FROM categories LEFT JOIN group_fields
ON categories.block_type=group_fields.id
WHERE categories.home_new='1' ORDER BY sorting ASC ")or die(mysql_error());
while($row_all    = mysql_fetch_array($select_all))
{
  $allcc[]      = $row_all;

  $tblname      =$row_all['id'];
  $select_grp   = $Drweb2->mysql_query("select * from $tblname");
  while($rrc    = $Drweb2->mysql_fetch_array($select_grp))
  {
    $rgcont[] = $rrc;
  }
  $smarty->assign('data',$rgcont);
}
$smarty->assign('allcc',$allcc);

这是聪明的 html 代码:

{section name=gac loop=$allcc}
{$allcc[gac].content}
{/section}

问题示例:[1]:http: //i.stack.imgur.com/mOHIg.png

4

1 回答 1

0

我假设 while 语句正在工作,但您没有遍历数组。

也许尝试:

$tblname      = $row_all['id'];
$select_grp   = $Drweb2->mysql_query("select * from $tblname");
$data         = $Drweb2->mysql_fetch_array($select_grp)
foreach ($data as $row) {
    $rgcont[] = $row; // or a specific field name using $row['field_name']
}

至于聪明人,你能这样做吗:

{section name=gac loop=$allcc}
    {$allcc[gac].content}
    {$allcc[gac].data}
{/section}

不确定这是否可行,但这是我最好的猜测。

于 2013-04-23T02:44:25.913 回答