I have a CSV file from which I extract the headers, which are actual fields in my MySQL tables using PHP's explode()
function. I don't know how many fields there will be in each CSV file, but I need to insert data dynamically in those fields.
For example:
array(
(int) 0 => 'admission_no',
(int) 1 => 'first_name',
(int) 2 => 'middle_name',
(int) 3 => 'last_name',
(int) 4 => 'gender',
(int) 5 => 'date_of_birth',
(int) 6 => 'join_date',
(int) 7 => 'form_id',
(int) 8 => 'stream_id'
)
The insert statement like INSERT INTO tbl_name (...) VALUES (...)
. I want the column names dynamically loaded from the array above, since I am not sure how many they will be. Can someone point me in the right direction?