mac007 Posted May 5, 2009 Share Posted May 5, 2009 Hi, all: Need help... I am trying to make it so that if some clicks on a specific category (in this case "clothing" category), it then echoes it's subcategories, but I want it to show it within the main "categories" array list. Right now, it displays/repeats the subcategory within each category, obvioously cause the if statement gets repeated in the while loop... hoe can I make it so the clothing "subcategories" only show within the "clothing" category area?? thanks!! <?php $query_categories = mysql_query("SELECT * FROM category"); while ($row = mysql_fetch_array ($query_categories)) { echo "<a href='workCategories.php?category=" . $row['category']. "'>" . $row['category']. "</a><br />"; ///// here is IF "clothing" category is selected show the "clothing subcategories (cat_id = 1)" if ($_GET['category']=='clothing') { $query_subcategories = mysql_query("SELECT * FROM subcategory WHERE cat_id = 1"); while ($row = mysql_fetch_array ($query_subcategories)) { echo "<a href='workCategories.php?category=" . $row['subcategory']. "'>" . $row['subcategory']. "</a><br />"; } } } ?> Quote Link to comment Share on other sites More sharing options...
mac007 Posted May 5, 2009 Author Share Posted May 5, 2009 OK, got it.. if it helps anybody: I added to the if statement: if (($_GET['category']=='clothing') && ($row['category']=='clothing')) and now the subcategory appears only in the "clothing" section of the array Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.