CSV import

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
fabby
Forum Commoner
Posts: 62
Joined: Tue Feb 15, 2005 1:06 am
Location: Romania
Contact:

CSV import

Post by fabby »

for the beginning, sorry for my bad english.. :)

i have a virtual magazin that is structurated lyke this:

main components(categ1) - > processor (categ2) -> AMD (categ3) - > Sempron 2600+ 64Bit TRAY(and the product with different caracteristics)

the database columns is made for category like this: id, name, id_parent

you insert the main component, with id=1 for example, the processor to have id=2, and id_parent=1(to be connected with categ1), the amd will have id=3, and id_parent=2(to be connected with the procesor), and the product, in separated table, with the id_parent=3

this site recieve product from the supplier, or, will be modified at the price, or other products, and it recieve in xls format. An exemple of products in xls:

Componente de baza Procesoare AMD Sempron 2600+ 64Bit TRAY
Componente de baza Procesoare AMD Sempron 2600+ 64Bit BOX
Componente de baza Procesoare AMD Sempron 2800+ TRAY socket A
Componente de baza Procesoare AMD Sempron 2800+ 32Bit TRAY


the problem is, that, for an simple operator, that dont know programming, how can he import csv in database structurated like this?

thanks!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

You might want to first try the import feature of OpenOffice Calc or other spreadsheets to get the data into columns.
(#10850)
fabby
Forum Commoner
Posts: 62
Joined: Tue Feb 15, 2005 1:06 am
Location: Romania
Contact:

Post by fabby »

can u give me a link, pls?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

I'm not sure I follow you but...

If your trying to import CSV data into a database...

You could possibly use the following class: viewtopic.php?t=47855 :P

You could then probably iterate the array and generate required SQL as a series of INSERT's and away you go :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

fabby wrote:can u give me a link, pls?
Most spreadsheets can do this: OpenOffice Calc, Microsoft Office Excel, etc.
(#10850)
Post Reply