我有3个表格,我对两个表格进行了一次查询 和while循环中的第二个表,这个表是结果视图中的问题 检查对unerstand问题的附件 这是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
答案 0 :(得分: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}
不确定这是否有效,但这是我最好的猜测。