469,362 Members | 2,441 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

How to get data from .CSV file using php & store it into Mysql database

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.
Sep 22 '06 #1
7 17516
ronverdonk
4,258 Expert 4TB
There is a code snippet at http://codewalkers.com/seecode/175.html that you could (maybe after some changes) use for your purpose.

Ronald :cool:
Sep 22 '06 #2
There is a code snippet at http://codewalkers.com/seecode/175.html that you could (maybe after some changes) use for your purpose.

Ronald :cool:

Thanks
this code is very useful for me.

but i want the code for reading data from two files & import it into mysql table
Plese give me the PHP code for this. & also i want the code for the php page is run daily at once automatically.
please help me to do this.

thanks
Sep 26 '06 #3
chumma
4
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.

Just try this at 1ce
<?php
$row = 1;
$handle = fopen("filename.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
?>
Apr 5 '07 #4
chumma
4
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);

?>
Apr 5 '07 #5
Thanks a lot
Oct 7 '10 #6
@ronverdonk

i want this code but the link was not working
Mar 5 '12 #7
How to get data from .CSV file using php & store it into Mysql database

I want to read data from single .CSV files using php & How to store it into Mysql Database tables

Please help me .
Mar 6 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Nomen Nescio | last post: by
5 posts views Thread by Lars Behrens | last post: by
4 posts views Thread by Holger Marzen | last post: by
12 posts views Thread by Chris Springer | last post: by
7 posts views Thread by Rudi Menter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.