Php, and mysql

please have a look at my mark up , what could be wrong


  
    <?php
	//3. perform database querry
	$subject_set = mysql_query("SELECT * FROM subjects", $connection);
	if (!$subject_set) {
		die("Database query failed: " . mysql_error());
		}
		//4 use returned data
	while($subject = mysql_fetch_array($subject_set)) {
		echo $subject["menu_name"]."<br />";
		$page_set = mysql_query("SELECT * FROM pages WHERE subject_id =
		{$subject["id"]}", $connection);
	if (!$page_set) {
		die("Database query failed: " . mysql_error());
		}
		//4 use returned data
	while($page = mysql_fetch_array($page_set)) {
		echo $page["menu_name"]."<br />";
		}
		?>
	</li>	
</ul>
</div> 

Two things:

  1. please fix your ‘highlight’ tags, might make it easier to read :slight_smile:
  2. what’s going wrong? What errors are you getting?

Well, the mySQL could use some refining, but lets leave that be for the moment.

I dont see any glaring syntactical errors… so i’m gonna echo Immerse’s statement and ask what’s wrong.

The first while loop is not closed.

it is not opening, and nothing in the view page source



    <?php
    //3. perform database querry
    $subject_set = mysql_query("SELECT * FROM subjects", $connection);
    if (!$subject_set) {
        die("Database query failed: " . mysql_error());
        }
        //4 use returned data
    while($subject = mysql_fetch_array($subject_set)) {
        echo $subject["menu_name"]."<br />";
        $page_set = mysql_query("SELECT * FROM pages WHERE subject_id =
        {$subject["id"]}", $connection);
    if (!$page_set) {
        die("Database query failed: " . mysql_error());
        }
        //4 use returned data
    while($page = mysql_fetch_array($page_set)) {
        echo $page["menu_name"]."<br />";
        }
        ?>
    </li>    
</ul>
</div>

got it thanks qmonkey, i closed the while loop and it worked, i just need to adjust it in the css, thanks for helping a newbie