我有拖车第一个表:对于产品第二个表:对于类别
i have tow tables first table : For products Second Table : For Categories
我想像这样在浏览器中显示
i want to show in browser like this
类别 1 (20)类别 2 (5)类别3 (3)
category1 (20) category2 (5) category3 (3)
$select_sub_cat = mysql_query("SELECT * FROM sub_cat WHERE ct_id='".$row_main['id']."' ");
while($row_sub = mysql_fetch_array($select_sub_cat))
{
$select_num_sub = mysql_query("SELECT * FROM market WHERE sub_cat='".$row_sub['id']."' ");
$row_num_sub = mysql_num_rows($select_num_sub);
$smarty->assign('numb',$row_num_sub);
$sub_cats[] = $row_sub;
}
$smarty->assign('sub_cats',$sub_cats);
尝试
$select_sub_cat = mysql_query("SELECT * FROM sub_cat WHERE ct_id='".$row_main['id']."' ");
while($row_sub = mysql_fetch_array($select_sub_cat))
{
$select_num_sub = mysql_query("SELECT * FROM market WHERE sub_cat='".$row_sub['id']."' ");
$sub_cats[] = $row_sub;
$sub_cats['count']=mysql_num_rows($select_num_sub);
}
$smarty->assign('sub_cats',$sub_cats);
然后打电话给你的聪明人:
and then call on your smarty :
{$sub_cats.name} ({$sub_cats.count})//$sub_cats.name 应该是类别的名称"
{$sub_cats.name} ({$sub_cats.count}) // $sub_cats.name should be 'name' of category
这篇关于循环时我无法在里面创建 num 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!