Import csv file in mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
biplob
Forum Newbie
Posts: 1
Joined: Fri Jul 10, 2009 12:46 am

Import csv file in mysql database

Post by biplob »

Hi,
I want to write a code in which .csv file can be import and it could be save in MySQL database.I have already created a database called import having table with id,name,size,type content.There shold be page in which we can browse .csv file and be uploaded.After that it could save in sql databse.
Please provide me the complete code.
Thanks in advance..
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Import csv file in mysql database

Post by requinix »

biplob wrote:Please provide me the complete code.
No. We'll help you but we won't write it for you.

Use fgetcsv to read from the file (after fopening first, of course), build the query, then use mysql_query to execute it.
A loop or two, maybe some fancy array work, and you're done.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Re: Import csv file in mysql database

Post by ddragas »

nobody here is going to write code for you, but point you in right direction .......

there are tons of examples on "http instances" how to do it

use functions

fgetcsv
mysql_query
peter162in
Forum Newbie
Posts: 12
Joined: Mon Jul 06, 2009 11:37 am

Re: Import csv file in mysql database

Post by peter162in »

USE PHPMYADMIN TO IMPORT CSV . IT IS VERY EASY AND SIMPLE RATHER GOING FOR A CODE.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Import csv file in mysql database

Post by califdon »

biplob wrote:Please provide me the complete code.
You may have noticed the subtitle of this forum: "The Developer's Network". If you want code written for you, you could post in the Jobs forum here and one of our developers might make a bid for writing it for you.
Post Reply