I would like to import Excel data into the MySQL database in phpmyadmin via wordpress backend.
The data in the spreadsheet is not ready for direct database import, I need to add other fields which depend on values in the excel spreadsheet.
For example for each row, if all 4 first columns are filled, I will have 4 lines of code in column 5, for each of the columns. If only 2 are filled, I will have 2 lines of code corresponding to those 2 columns.
This last column will be imported into phpmyadmin.
I'm trying to see whether I should do it via php. Create a while loop for each row, and use and try something like (col(i) is simply the content of the cell):
INSERT into table VALUES ('col1','col2','col3','col4','{$col5}')
Now for $col5 variable, it should be in format (in the case all are non-empty:
Columns:(4). Code for column 1, Code for column 2, Code for column 3, Code for column 4.
static $nonempty = 0;
if(!empty(col1) {
$nonempty = $nonempty + 1;}
if(!empty(col2) {
$nonempty = $nonempty + 1;}
if(!empty(col3) {
$nonempty = $nonempty + 1;}
if(!empty(col4) {
$nonempty = $nonempty + 1;}
$code1 ="";
if(!empty(col1)) {$code1 = "Code for 1"}
$code2 =""
if(!empty(col2)) {$code2 = "Code for 2"}
...
$col5 = "Columns(".$nonempty.")".$code1.", ".$code2.", "...
Is the above idea right? How can I associate values from the excel table with the col1 , col2 , col3 , col4 variables?