473,549 Members | 2,568 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 17886
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
4426
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
3387
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
2787
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...
4
4015
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...
3
5745
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
3740
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...
3
2349
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
1583
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
17732
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
7726
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. ...
1
7485
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...
0
6052
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...
0
5097
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...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1953
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
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
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...

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.