Importing .csv file into mysql in php

I have a .csv file with me but i am unable to import it into the database. I have parsed my .csv file using the below query. Can you please help me how to insert data into MySql.

My code is:-
$fp = fopen(‘test.csv’,'r’) or die(“can’t open file”);
print “\n”;

while($csv_line = fgetcsv($fp,1024)) 
{
print '<tr>';
for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
    print '<td>'.$csv_line[$i].'</td>';
    $data[] = $csv_line[$i];
}
print "</tr>\n";
}
print '</table>\n';
fclose($fp) or die("can't close file");

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories