php - how to fetch main category and nesting there subcategory between them one by one using mysql -


i want display main category , between them show belonging sub-category. want display sub-category belong particular main category database. in database 2 different table category , sub-category. here code. problem things working sub-category repeating again again how limit them want display 1 time particular sub-category.

<div class="product_right"> <h4 class="m_2"><span class="glyphicon glyphicon-minus" aria-hidden="true"></span>categories</h4> <?php $mysqldata = mysql_query("select * `sub_category` group `name` desc"); while($mysqlfetchrows = mysql_fetch_assoc($mysqldata)) {     $mcat = mysql_fetch_assoc(mysql_query("select * `category` `id`='".$mysqlfetchrows['cid']."'")); ?> <div class="tab1"> <ul class="place">                <li class="sort"><?php print $mcat['name'];?></li> <li class="by"><img src="images/do.png" alt=""></li> <div class="clearfix"> </div> </ul> <div class="single-bottom">             <a href="#"><p><?php print $mysqlfetchrows['name']?> </p></a>  </div> </div>   <?php } ?>  


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -