I have an upload script and I need to make it work with a function that can do the following:
- Read from a CSV file, separator is ","
- The first row in the CSV is the table names, those are the exact same names used in the database in that table so "id" equates to an "id" column in the table same as "city" equates to a "city" column in the table, etc. There are a total of 30 columns in the database table.
- Columns are not in the same order so matching columns regardless of position is needed
- Build an SQL query that UPDATES and INSERTS records from the csv according to the following 2 rules:
* One column is the ID, if the ID is set that means that the record exists and needs to be UPDATEd in the database.
* If the ID field is empty in a row that means that the record doesn't exists and needs to be INSERTED in the database
Just to be clear I have the upload script working and the only thing I need from you is to develop a script that handles the insert and update of the records in the MySQL database as explained above, hopefully in a class/function fashion.
Payment will be 50% when you show me the program working and 50% after I test the code and all possible issues had been resolved.
34 freelancers are bidding on average $80 for this job
I think, I will need the CSV to investigate some details. Moreover, if column position might differ, then do you ensure that there is a header row which contains column names?
Cheers, +5 years experience in Web development ( PHP/SQL) and data processing. I can finish your script today , error free . Let me know if you need my services.