Here is the code …
<?php
$query = mysql_query("SELECT * FROM subjects");
while($fetch = mysql_fetch_array($query)){
echo "<li>" . $fetch["menu_name"] . "</li>";
echo "<ul>";
$query = mysql_query("SELECT * FROM pages WHERE subject_id = {$fetch["id"]}");
while($fetch = mysql_fetch_array($query)){
echo "<li>" . $fetch["menu_name"] . "</li>";}
echo "</ul>";
}?>
the problem is that it gets one “subject” and the rest of the “pages” under it …
I want it to get all subjects and all pages under it
I hope that you understood me
Thanks in advance
FarrisFahad
I might be wrong. But possibly because you are using the variable
$queryfor both of the mysql queries. Try using a different variable, such as$query1or an other such useful name for the inner one.