i can't make num rows inside while looping

前端 未结 2 1116
陌清茗
陌清茗 2021-01-28 04:51

i have tow tables first table : For products Second Table : For Categories

i want to show in browser like this

category1 (20) category2 (5) category3 (3)

2条回答
  •  故里飘歌
    2021-01-28 05:39

    Try this:

    $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']."' ");
      $smarty->assign('numb',$row_num_sub);
    
     $sub_cats[] = $row_sub;
     $sub_cats['count']=mysql_num_rows($select_num_sub);
    }
    $smarty->assign('sub_cats',$sub_cats);
    

提交回复
热议问题