Reputation: 5437
hi i am making a menu module whose menu items will be fetched from the database. i have two tables in the database which names are main_module and second is sub_module. i have a primary key "module_id" in the main_module table and this is foreign key in second table.
the columns of first main_module table are
module_id
module_name
and for sub_module table the columns are
main_module_id(F)
sub_module_id
sub_module_name
the data in first table are
1 Home
2 Conf
and data in second table are
1 1 dashboard
1 2 bulletin board
2 3 site configuration
2 4 meta data
now i want to populate these items dynamically in a css menu. so how to do this. please help me.
thanks.
Upvotes: 0
Views: 181
Reputation: 4221
Assuming you have connected to the database, and retrieved the data, you can loop the result inside a ul tag:
echo "<ul>";
while($each_row=$result->fetch_row()) // this is the object version;
{
echo '<li><a href="whatever the link is">' . $each_row[index_of_needed_column] . "</a></li>";
}
echo "</ul>"
That will ensure the navigation is created. If you want to float or do any styling to it, add a class to the ul, and just style it accordingly.
That rough sample should give you something with which to start
Upvotes: 1