PHP to Create and Populate HTML Table Vertically with DB Data

Job ID: 34298486

Budget: $10 – $30 USD

I would like to populate an HTML table vertically, pulling USA states from a database. Instead of the USA states in the database being populated left-to-right in rows... I want the USA states in the database being populated top-to-bottom in columns. There is a max of 4 columns.

The max number of columns that will fit in our modal is 4 (four). So populating the states, or any other additional entities we want to place into the database, should distribute the columns with even amounts in the first 3 columns... with the fourth (and final, right-most) column allowed to have less than the first 3 columns. So, as we can see in this example of 51 states:

13 in column ONE, 13 in column TWO, 13 in column THREE, and 12 in column FOUR.

But... we may have data with different total states, so some math will have to be done to calculate the first 3 columns to the same number... and the 4th column to have less (unless all 4 columns have the same amount, of course).

I will provide the HTML template that we have created, and is pictured in an attachment... so that you can possibly use loops to get this done. (But, the solution is up to you.) It can be JavaScript... but remember that we use PHP to get the data from the database.

Also, the sort order is based on "iso_alpha2" column seen in screen capture of database.e

Attached is a visual explanation... please let me know of any questions!
Related categories: PHP JavaScript MySQL HTML jQuery