raven2009 Posted April 7, 2009 Share Posted April 7, 2009 hi all ive been learning php doing well so far until... i come to the subcategories right what i aim to do is that the left pannel displays the maincat then if a user clicks on a main cat that has a subcat then the cat menu expands to enclude both, heres my code below to see where ive gone wrong any help will be much appriciated ) <?php $categories="select * from categories where parent='0' order by id"; $listCats=mysql_query($categories); while($row=mysql_fetch_array($listCats)) { ?> <tr> <td height="15" bgcolor="#006699"><h5><img src="Images/arrwo_4.png" alt="" width="10" height="7" /></h5></td> <td bgcolor="#006699"><h5><a href="storesinfo.php?s=<?php echo $row['id']; ?>" class="White"><font color=""><?php echo $row['category']; ?></font></a></h5></td> </tr> <?php $parId=$row['id']; $childCategories="select * from categories where parent='$parId' order by id"; $listChildCategories=mysql_query($childCategories); while($rowC=mysql_fetch_array($listChildCategories)) { ?> <tr> <td height="15" bgcolor="#009900"><h5> </h5></td> <td bgcolor="#009900"><h5><a href="storesinfo.php?s=<?php echo $rowC['id']; ?>" class="White"><font color=""><?php echo $rowC['category']; ?></font></a></h5></td> </tr> <? } } ?> <?php if(isset($_GET['p'])) { $p=$_GET['p']; $categories="select * from categories where parent='$p'"; } else { $categories="select * from categories"; } $listCats=mysql_query($categories); while($row=mysql_fetch_array($listCats)) { ?> <?php Link to comment https://forums.phpfreaks.com/topic/152969-subcat-problem-can-anyone-help/ Share on other sites More sharing options...
raven2009 Posted April 7, 2009 Author Share Posted April 7, 2009 sorry all ill explain better main cat is displayed constant then if user clicks on a main cat that has a sub cat then the subcat will open is it possible? Link to comment https://forums.phpfreaks.com/topic/152969-subcat-problem-can-anyone-help/#findComment-803396 Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 Please surround code with CODE tags to help preserve formatting. Link to comment https://forums.phpfreaks.com/topic/152969-subcat-problem-can-anyone-help/#findComment-803402 Share on other sites More sharing options...
raven2009 Posted April 7, 2009 Author Share Posted April 7, 2009 sorry, dunno if this is right but he it goes <?php $categories="select * from categories where parent='0' order by id"; $listCats=mysql_query($categories); while($row=mysql_fetch_array($listCats)) { ?> <tr> <td height="15" bgcolor="#006699"><h5><img src="Images/arrwo_4.png" alt="" width="10" height="7" /></h5></td> <td bgcolor="#006699"><h5><a href="storesinfo.php?s=<?php echo $row['id']; ?>" class="White"><font color=""><?php echo $row['category']; ?></font></a></h5></td> </tr> <?php $parId=$row['id']; $childCategories="select * from categories where parent='$parId' order by id"; $listChildCategories=mysql_query($childCategories); while($rowC=mysql_fetch_array($listChildCategories)) { ?> <tr> <td height="15" bgcolor="#009900"><h5> </h5></td> <td bgcolor="#009900"><h5><a href="storesinfo.php?s=<?php echo $rowC['id']; ?>" class="White"><font color=""><?php echo $rowC['category']; ?></font></a></h5></td> </tr> <? } } ?> <?php if(isset($_GET['p'])) { $p=$_GET['p']; $categories="select * from categories where parent='$p'"; } else { $categories="select * from categories"; } $listCats=mysql_query($categories); while($row=mysql_fetch_array($listCats)) { ?> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/152969-subcat-problem-can-anyone-help/#findComment-803407 Share on other sites More sharing options...
raven2009 Posted April 7, 2009 Author Share Posted April 7, 2009 anyone? ??? Link to comment https://forums.phpfreaks.com/topic/152969-subcat-problem-can-anyone-help/#findComment-803538 Share on other sites More sharing options...
raven2009 Posted April 7, 2009 Author Share Posted April 7, 2009 no? :'( Link to comment https://forums.phpfreaks.com/topic/152969-subcat-problem-can-anyone-help/#findComment-804007 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.