1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Uploading a csv file to a mysql database using php

Discussion in 'Software' started by kopite, 22 Sep 2005.

  1. kopite

    kopite What's a Dremel?

    Joined:
    3 Dec 2001
    Posts:
    247
    Likes Received:
    0
    As title.

    I am trying to upload a CSV files content to my Mysql database.

    I know this can be done using PHPmyadmin But I want to be able to do this via a webpage.

    I also want to be able to add data to another field which isnt in the cvs.
    e.g

    CSV has

    name code status data

    I then want to add todays date to each line as its inserted.

    Anyone got any ideas
     
  2. Nedsbeds

    Nedsbeds Badger, Slime, Weasel!!

    Joined:
    16 May 2002
    Posts:
    1,972
    Likes Received:
    9
    fgetcsv should do you.

    Just open a file pointer and then it basically gives you an array of all the data in the csv. Then add it to the database as normal.

    http://uk.php.net/fgetcsv

    Ned
     
  3. kopite

    kopite What's a Dremel?

    Joined:
    3 Dec 2001
    Posts:
    247
    Likes Received:
    0
    Found that soon after posting hehe.

    Had a spot of bother getting the insert command to work but thats now sorted.

    Now all I need to do is get it to pull the data from a file hosted on the client side instead of server side and I`m laughing
     

Share This Page