Saturday, 13 May 2017

PHP Array to MYSQL database?

I have an table that looks like this:
















































Totals/Avg Column 1 Column 2 Column 3 Column 4 Column 5 Column 6
Row Info 1 5,400.00 900.00 900.00 900.00 900.00 900.00 900.00
Row Info 2 6,000.00 1,000.00 1,000.00 1,000.00 1,000.00 1,000.00 1,000.00
Row Info 3 535,547 91,186 90,148 89,694 90,900 90,662 82,957



Using the information I found here: How to parse this table and extract data from it?




I was able to get the data into arrays:



Array
(
[0] =>
[1] => Array
(
[] => Row Info 1
[Totals/Avg] => 5,400.00

[Column 1] => 900.00
[Column 2] => 900.00
[Column 3] => 900.00
[Column 4] => 900.00
[Column 5] => 900.00
[Column 6] => 900.00
)

[2] => Array
(

[] => Row Info 2
[Totals/Avg] => 6,000.00
[Column 1] => 1,000.00
[Column 2] => 1,000.00
[Column 3] => 1,000.00
[Column 4] => 1,000.00
[Column 5] => 1,000.00
[Column 6] => 1,000.00
)


[3] => Array
(
[] => Row Info 3
[Totals/Avg] => 535,547
[Column 1] => 91,186
[Column 2] => 90,148
[Column 3] => 89,694
[Column 4] => 90,900
[Column 5] => 90,662
[Column 6] => 82,957

)

)


What I need to do, is store the data into mysql, laid out like with the actual data in place of the Row Info:



Column 1 - Row Info 1 - Row Info 2 - Row Info 3



I've been banging my head on this all night soo here Iam.




Edit:
What I need to do is basically arrange the array so I can store it as such



Array
(
[0] =>
[1] => Array
(
[] => Column 1

[Row Info 1] => data
[Row Info 2] => data
[Row Info 3] => data
)

[2] => Array
(
[] => Column 2
[Row Info 1] => data
[Row Info 2] => data

[Row Info 3] => data
)

[3] => Array
(
[] => Column 3
[Row Info 1] => data
[Row Info 2] => data
[Row Info 3] => data
)

...etc

)

No comments:

Post a Comment