How to get data from .CSV file using php & store it into Mysql database
I want to read data from two different .CSV files using php & How to store it into Mysql Database tables
Please help me to do this.
Here it is My Sample Codings, Itz Working....
<?php
$conn=mysql_connect("localhost","root","") or die("unable to connect localhost".mysql_error());
$db=mysql_select_db("mysql_db_name",$conn) or die("unable to select db name");
$file=fopen("Filename.csv","r");
while(($var=fgetcsv($file,1000,","))!==FALSE)
{
$var1=$var[0];
print_r($var);
$ro=mysql_query("select username from user where username='$var1'");
$ro1= mysql_num_rows($ro);
echo $ro1;
if($ro1<1)
mysql_query("insert into user(username,password,age,company) values('$var[0]','$var[1]','$var[2]','$var[3]')");
}
fclose($file);
?>