I'm trying to learn some of the new (at least for me) aspects of PHP and I'm struggling with a simple menu I'm trying to fill up from the DB. If I was using the old query method (MYSQL or MYSQLi), it would be easy as throwing a bunch of while and foreach loops with a couple calls to the DB. The thing is that I'm very interested in learning how to work with PDO and prepared statements (not just query()) so if anyone wants to give me some tips on how to look at this it would rock. Actually an example would be better. I learn by looking at structured code. Unfortunately all samples I've seen involve too much or too little (for example no prepared or no iterations).
What I have is a couple of tables. One for categories, another for subcategories and a third one for indexes (like sub-subcategories). For now, being capable of calling stuff from the first two would be just fine:
And I need to get something like this:
<li><a href="#">FIRST CATEGORY NAME</a></li> // item 1 from 1st table
<ul class="dropdown-menu" aria-labelledby="themes">
<li><a href="#">FIRST SUB-CAT OF FIRST CAT</a></li> // item 1 from 2nd table
<li><a href="#">SECOND SUB-CAT OF FIRST CAT</a></li> // item 2 from 2nd table
That's it... something simple BUT, I really want to learn how to do this with PDO, prepared statements and iterations inside a class (very new to classes too - that's something I also want to learn). Any ideas?
Thanks in advance!!!!!!