I am trying to validate two things before I upload a csv file in my database table. This I want to achieve with PHP and MYSQL
1. that the content in the file is of csv format
2. I want to validate that the contents of two particular columns is as per the contents of my existing tables in the database.
I know the first point is clear but for second point you are a bit confused. Let me explain:
There are two existing tables in my database for example table_1
. The file that I am uploading will be imported into a third table table_3
id number name location person date
1 12345 name_1 loc_1 person_1 09-09-2014
2 23456 name_2 loc_1 person_1 10-09-2014
3 34567 name_1 loc_1 person_4 11-09-2014
4 45678 name_5 loc_1 person_5 12-09-2014
5 56789 name_3 loc_1 person_5 13-09-2014
Before I import the table_3 data using a csv file into database. I want to validate that the entries in the name
columns be exactly the same way that they are in the table_1
respectively. The name and person columns in table_3 should not have an entry which is not present in the table_1 and table_2 respectively. OTHER COLUMNS CAN HAVE ANY DATA DOESN'T MATTER
I hope I have cleared myself. If any more inputs required then do let me know.