473,902 Members | 3,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 17900
ronverdonk
4,258 Recognized Expert Specialist
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
mukeshpatil
2 New Member
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 New Member
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 New Member
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);

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

i want this code but the link was not working
Mar 5 '12 #7
jeya1985
4 New Member
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
4456
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 part, the scripts were created with http://phpcodegenie.sourceforge.net/
5
3405
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 attendants of a congress. In a form the user will submit name, mailadress etc. and I plan to store the data in a list of dictionaries: People =
4
2826
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 http://192.168.1.106/~mlh/credifree/index.php the AMP app still thinks the data resides somewhere else. It runs fine - as long as I leave my LAN's external internet connection up. But if I unplug my LAN from the world, my app locks up. Before I...
4
4047
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 without the complicated lo-stuff? Of course it's in many cases a good approach to store those files simply in the file system but there's always a risk of running out of sync (filesystem and tables), e.g. by deleting files and not deleting the table...
3
5783
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 drive onto a USB External Hard Drive. I have to assume I also copied the data. I
12
3776
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 question is about storing data in a database. Yes I understand that you can link to a database in your program and read and write to the database etc etc. Well, that's all find and dandy but what if the person you're writing the application for...
3
2363
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 convert my DB into a binary file? and how to convert my code to use a file instead of the db?
7
1602
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 this task that you know of? Thx, Regards --
3
17754
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
9997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11279
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10981
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9675
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7205
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3323
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.