473,388 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 17861
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

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

Similar topics

4
by: Nomen Nescio | last post by:
can anyone be so kind as to look at http://www.mysolution.ws/HYPOCRITE.php and let me know why it isn't passing the form data to http://www.mysolution.ws/insertHYPOCRITES.php for the most...
5
by: Lars Behrens | last post by:
Hi there! For a web project I need a little expert help. I don't have written much code yet, just been fiddling around a bit, testing and planning. The web site will have a submission page for...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
4
by: Holger Marzen | last post by:
Hi all, AFAIK it is possible for columns to be very large, up to about 2 GB. Are there any hints or experiences about storing binary data (jpg-images, pdf-documents) in PostgrreSQL with or...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
3
by: VB.NET | last post by:
I'm using a mysql database and connecting my vb.net program to the DB over a network connection. i would like to bring this data over to a vb.net random access file. does anyone know how to...
7
by: Rudi Menter | last post by:
Hi, I would like to store binary data (as data-type blob) in a (MySql-) database, so I require functionality that allows a mapping from and back into the filesystem. Now, is there a library for...
3
by: kiranrredy | last post by:
Hi, I need to get the data from XML file and store it in MySql database. How can i do it,could you please tell me. Regards, KiranRredy
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.