I’m trying to run 2 while statements with 2 separate queries. One gets the main categories, the other gets the sub categories. What happens is that the second query for the sub categories will only get the second listing and no other ones. Here’s the code
[php]
<?php //SECOND LINE /*Needs to run 2 queries. One to recieve the main categories and one to recieve the * sub categories. */ $mainlinks = mysql_query("select * from ns_categories"); while ($catlinks = mysql_fetch_array($mainlinks)) { $catlinkname = $catlinks['name']; $catlinkid = $catlinks['id']; $sublinks = mysql_query("select * from ns_subcategories where mainid='$catlinkid'"); echo "- ";
echo "
- $catlinkname "; while ($catsublinks = mysql_fetch_array($sublinks)) { $sublinkname = $catsublinks['name']; $sublinkid = $catsublinks['id']; echo "
- <a href='products.php?sc=$sublinkid>$sublinkname</a></li>"; echo "</ul>"; echo "</ul>"; } } ?> <p>[/php]</p>
- ";
echo "