Forum Moderators: coopster
Since I've become so enthused about drawing content from a database and displaying it via php, my latest brainstorm is to put navigation items into their own table and have them dynamically displayed when each page loads.
My reasons are that if a client needs to change or add a link to the nav list - which has happened more times than I'd like to remember - I don't have to sweat blood changing or adding the link to each page on the web site by hand or semi-automated means - I'd just make the alteration once in the nav table. This approach, to me, is way cool.
But is this taking the whole php/database experience a little too far? Have I, indeed, gone over the edge? Or do others do this with successful, user-tranparent results?
One thought that crossed my mind is that, if I do this, will the speed of drawing each page suffer dramatically as I open/query/close the db and then use a loop to display the links?
I haven't done this yet, but am aching to. But before I dive in, I'd love to know the pros and cons of such an idea.
Thanks to all in advance.
Neophyte
beginning to think that I'm going overboard with my desire to put the kitchen sink into a database
Dynamically producing links, though, is probably one of the best uses of databases. Not just having a table called 'links' that you can edit at will - but allowing your site to produce links to your content per category, or whatever your site navigation principle is. You can also have an additional table of standard links to be displayed for different pages or sets of pages - that one little extra 'select' won't hurt too much, the people at mysql.com say that the biggest overhead factor is often the connection to the database itself. But like you said, you don't want to go overboard with the whole dynamic content thing, because if you really *must* show the number of users surfing your site who live in Alabama, etc., etc., you'll get very much lagged down. Once you're thinking about db efficiency, you can also think of things like : is there any way I can get all the info I want from as few queries as possible, instead of querrying the é"(§ out of the db?
Another method you can use for stuff you want easily changeable, but that doesn't have to be too automated, is just strategically using include files. A nice, clean list all by itself, just a few seconds away via ftp.
Thanks for the reply ... I'm pleased to know that my plan is not extraordinary or foolish.
One follow-on question: I've put a comma-delimited list of all link names into a single "text" table field rather than using individual fields for each link name. When I query that field, I'm using explode() to feed the result into an array from which I loop through and display the results.
Is this a good practice for what I'm trying to do, or would you/others choose to include each link name into individual fields of the same row?
Neophyte