Forum Moderators: coopster

Message Too Old, No Replies

How do I get a csv file into a msql table with PHP?

         

Craig_F

8:30 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



I've searched a good bit at google and the php site and all I keep finding are tutorials showing how to insert one line into msql table, but I need to dump about 500 lines of data from a csv file.

Can anyone point me in the right direction? I'm not looking to solve this in this thread (I should try to learn on my own first), but it would be great if someone could put me on the right path. thanks!

gettopreacherman

8:50 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



phpmyAdmin...

ogletree

8:55 pm on Mar 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes just install phpmyadmin. All you have to do is download it put it in a new directory on your site called /phpmyadmin or something would be safer. It would be best to password protect the directory if you can. It is not hard to do let us know if you don't know how to do that. It is very easy to install let us know if you have any problems.

Craig_F

8:57 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



> phpmyAdmin...

ok? I know how to do one line at a time in there, but that's all. Can I somehow dump my whole csv in there?

Craig_F

8:58 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



didn't see your post ogle, I do have phpmyadmin, but I only know how to insert one row at a time...

Craig_F

9:10 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



ok, i just found the "Insert data from a textfile into table" link (strange it's not on the insert tab). is that what you were referring to?

That looks like it would do the job, but I'm confused by "Fields terminated by" and "Fields enclosed by". My file is a csv, so it has commas for both. Do I just put a comma in each box? Somehow I know that is not correct.

gettopreacherman

9:12 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



That's the location. Dump the file...fields ended by "," comma.