I’ve searched the web trying to find examples of how to store tabular data in MySQL and loop through the rows to assemble a table using PHP, but no luck.
Here is a sample of my Excel file that I want to insert into MySQL. I then want to display it with PHP/HTML in its tabular form.
Keep in mind I have a lot of tables exactly like this for different countries so I am looking for a good MySQL schema to efficiently store this data, then have PHP make use of it by looping through the rows and id’s to pull the correct data.
How would you store this in MySQL?
How would you loop through the database with PHP to build columns?
I concur with Kalon also you may want to get a great book by Kevin Yank of Sitepoint Database driven website. It was a great start for me Christmas 4 years ago now.
yep, data that can be calculated from stored data should not be stored in the database itself.
another option to calculating it in the application (php or whatever) is to calculate the “column” as part of the sql query retrieving the records from the database
Yet another way to do the summaries might be to do it on the client, I’ve got column (vertical) summaries working like that in the past, but not row (horizontal) totals at the same time I must admit (though I cannot easily see what “growth rate” is deduced from)
Seeing the totals would then be dependent upon JS being turned on of course.