I'm making a web site with php and bootstrap... I've loaded navitems from database and applied bootstrap style to it.. I'm having issues with the "dropdown" class because I honestly don't know how to write an if statement that would do something like "if $subject has $page, add class dropdown to $subject"..$subject are the main navitems and $page are the items that are visible when the dropdown is clicked... right now when the $subject without $page is clicked it shows an empty box a few px high and about 40px wide..
here's my code...
<ul class="nav navbar-nav">
<?php $subject_set = find_all_subjects(); ?>
<?php
while($subject = mysqli_fetch_assoc($subject_set)) {
?>
<?php
echo "<li class=\"navitem dropdown" ;
if($subject["id"] == $selected_subject_id) {
echo " active\"" ;
}else{
echo "\"" ;
}
echo ">" ;
?>
<a href="admin.php?subject=<?php echo urlencode($subject["id"]); ?>">
<?php echo $subject["menu_name"]; ?>
</a>
<?php $page_set = find_pages_for_subject($subject["id"]) ; ?>
<ul class="dropdown-menu" role="menu">
<?php
while($page = mysqli_fetch_assoc($page_set)) {
?>
<li>
<a href="admin.php?page=<?php echo urlencode($page["id"]); ?>"><?php echo $page["menu_name"]; ?> </a>
</li>
<?php
}
?>
<?php
mysqli_free_result($page_set);
?>
</ul>
</li>
<?php
}
?>
<?php
mysqli_free_result($subject_set);
?>
</ul>
I would be very grateful if someone would write that code for me... :)
Keep in mind that I'm a noob at this...be gentle... :)