Hi Chaps,
I have a dynamic menu which shows the category names in a database, then the gallery names, to which they are linked:
// QUERY
// MenuCode:mysql_select_db($database_dbconnect, $dbconnect); $query_rsCategory = " SELECT tbl_category.catid, tbl_category.catname, tbl_gallery.galleryid, tbl_gallery.galleryname, tbl_gallery.FK_catid FROM tbl_category INNER JOIN tbl_gallery ON tbl_gallery.FK_catid=tbl_category.catid ORDER BY catname ASC, galleryname ASC"; $rsCategory = mysql_query($query_rsCategory, $dbconnect) or die(mysql_error()); //$row_rsCategory = mysql_fetch_assoc($rsCategory); $totalRows_rsCategory = mysql_num_rows($rsCategory);
The Categories are repeating through the loop, but the problem is the Galleries aren't repeating (only one gallery per category).Code:<ul> <li><a href="#"><span>Home</span></a></li> <li><a href="#"><span>Portfolio</span></a> <ul> <?php $previousCategory = ''; if ($totalRows_rsCategory > 0) { // Show if recordset not empty do { if ($previousCategory != $row_rsCategory['catname']) { // for every Category, show the Category Name ?> <li> <a href="#"><?php echo $row_rsCategory['catname']; ?></a> <ul> <li> <a href="#"><?php echo $row_rsCategory['galleryname']; ?></a></li> </ul> </li> <?php $previousCategory = $row_rsCategory['catname']; } ?> <?php } while ($row_rsCategory = mysql_fetch_assoc($rsCategory)); ?> <?php } // Show if recordset not empty ?> </ul> </li> <li><a href="#"><span>Info</span></a></li> <li><a href="#"><span>Contact</span></a> <li><a href="#"><span>Admin</span></a></li> </ul>
How can I repeat the Galleries, for every Category?







Bookmarks