download file csv and xls
Insert Data in mysql with csv file
<?php
mysql_connect('localhost','root','');
mysql_select_db('Databasename
');
$fop = fopen("city.csv",'r');
//print_r(fgetcsv($fop));
$i=0;
while($ow = fgetcsv($fop))
{
//print_r($ow);
if($i!=0)
{
//echo "<pre>";
//print_r($ow);
mysql_query("insert into cities set cityName='".$ow[1]."',state_code='".$ow[0]."',countryID='IN'");
}
$i++;
}
?>
Insert Data in mysql with csv file
<?php
mysql_connect('localhost','root','');
mysql_select_db('Databasename
');
$fop = fopen("city.csv",'r');
//print_r(fgetcsv($fop));
$i=0;
while($ow = fgetcsv($fop))
{
//print_r($ow);
if($i!=0)
{
//echo "<pre>";
//print_r($ow);
mysql_query("insert into cities set cityName='".$ow[1]."',state_code='".$ow[0]."',countryID='IN'");
}
$i++;
}
?>
No comments:
Post a Comment