SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    858
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Wanting to allow uploading Excel records into mySQL

    Right now my contact manager website allows users to enter one new contact at a time. However, I can forsee the need to add hundreds at once, to save them the time in retyping everything.

    Is there an easy way to upload rows in an Excel spreadsheet to a mySQL database? Is Excel the most popular format that I would want to accept?

    Thanks!

  2. #2
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Your best bet is to have your users save the Excel file as a CSV (Comma seperated values) file and upload that. The CSV is easy to work with. Each field is seperated by a comma and every row is seperated by a new line.

    You would parse the CSV and insert each row (probably using a loop) and get your data that way.

  3. #3
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    858
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    To go this route, I would probably need to make sure that each of my users presents their data in their CSV the same way....right? (firstname, lastname, address, city, etc...)

    Is there a place on the web where I can see a PHP example?

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2003
    Location
    United Kingdom
    Posts
    2,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would also like to know more about this and if there is a script that I can use then I would like to know where it is if anybody knows.

    The reasons for this is because I am doing a project where it will involve me uploading large amounts of data to my mysql database in one go.

    So please could somebody help.

    Thanks!

  5. #5
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to lok at LOAD DATA INFILE.

    If, however, you need to process the CSV data in some way, an dyou are using PHP, then look at fgetcsv.

    Hope this helps


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •