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_con nect("localhost ","root","" ) or die("unable to connect localhost".mysq l_error());
$db=mysql_selec t_db("mysql_db_ name",$conn) or die("unable to select db name");
$file=fopen("Fi lename.csv","r" );
while(($var=fge tcsv($file,1000 ,","))!==FAL SE)
{
$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("in sert into user(username,p assword,age,com pany) values('$var[0]','$var[1]','$var[2]','$var[3]')");
}
fclose($file);
?>