How to Design a Database Driven PHP Page
Design a Database Driven PHP Page
Many PHP pages turn into a mess because the PHP code is embedded into the HTML and. Over time this gets more and more tangled as the requirements change.
What is required is to make all the necessary database queries and all the manipulation of the data BEFORE you reach the first tag.
All that should appear in the HTML are the various php echos to output the dynamic parts of the page.
So here is the structure of a PHP page
| query database |
| insert data from queries into php arrays (hashs) |
| General functions |
| Main section call functions, which manipulate the data to get that required by the dynamic web page |
| html section |