SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    populating database with Excel

    Is it possible to use MS Excel spreadsheet to populate a database or to convert into a database. I have one that is supplied by a supplier containing information and prices on their products. I want to be able to use access this when calculating estimates. Can it be done with PHP or will I have to hand insert all information when it is updated?
    Pat

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Open it in Excel and save it back out as a CSV (it's one of the supported types in the Save As dialog). Then use fgetcsv to parse the CSV file, and for each row, create an INSERT or UPDATE query.

  3. #3
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank-you very much Dan, that will really help. To bad I cant use an excel file that has math calculations in it. That would save lots of work in the PHP side of it.
    Pat

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, the results of the calculations will be in the CSV file.

  5. #5
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again Dan do you happen to have some good recommendations on tutorials to learn how to do this? All I would have to do then is change a few things as prices changed.
    Pat

  6. #6
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The PHP manual page has examples of how to use fgetcsv

    What database are you going to use to store the price info? Have you ever worked with PHP and a database before? SitePoint has a couple books depending on what you need to learn, such as "Simply SQL" to learn about writing database queries, or "Build Your Own Database Driven Site With PHP & MySQL" to learn about creating dynamic database-driven websites step-by-step by creating a simple CMS.

  7. #7
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will be using Mysql as a database. I have read a few books but they are now more or less out dated. I know a little PHP and Mysql from what I have read and played with in my oscommerce shopping cart. I am constantly reading on this form. It is actually to only one I go to to help me learn. I have someone whom knows a lot on PHP and Mysql going to help me put this all together. He has volunteered to tutor me or point out what I am doing wrong. And when I do get stuck I come and ask questions here I have read more than one time Luke Welling and Laura Thomson's book PHP amd MySql web development. But like I said it is older (second Edition)
    Pat

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,323
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    use mysql's LOAD DATA INFILE command -- it handles csv files without breaking a sweat
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •