1 Replies - 858 Views - Last Post: 30 October 2013 - 11:07 PM Rate Topic: -----

#1 divyakv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-October 13

import csv to mysql using php

Posted 30 October 2013 - 10:12 PM

csv data is of

GU-#528B,,Default,simple,Flower Girl Dresses,base,Fuchsia Baby Flower Dress,"New Style, Fuchsia Baby Flower Dress","New Style, Fuchsia Fancy Baby Dress",0.5,,,2,fuchsia-baby-flower-dress,4,,60,29.99,6/26/2012 0:00,,,5,1,,,,,,,,,,,,,,,,2,1,KG __long,KG __long,No,Fuchsia,,United States
,,,,Shop by Color,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,Shop by Design,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,Shop by Size,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,Shop by Design/With Sleeves,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,Shop by Size/Infant (0-24mo),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,Shop by Color/Fuchsia,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,Shop by Design/Baby Pageant Dresses,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

the data inserting into database with one id as gu-#528B
but all the remaining rows also sholud save with the same id i.e gu-#528B

the code

if (($handle = fopen( $csv_file, "r")) !== FALSE)
$header = fgetcsv($handle);

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
$sql ="INSERT INTO ctpdata (sku,category,name,description,price,specialprice,path,color,title) values('$data[0]','$data[4]','$data[6]','$data[7]','$data[16]','$data[17]','$con$data[58]','$data[43]','$data[137]')";


If anybody hav idea about it plzzz help me

This post has been edited by Dormilich: 01 November 2013 - 03:32 AM
Reason for edit:: please use [CODE] [/CODE] tags when posting code

Is This A Good Question/Topic? 0
  • +

Replies To: import csv to mysql using php

#2 astonecipher  Icon User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2490
  • View blog
  • Posts: 9,977
  • Joined: 03-December 12

Re: import csv to mysql using php

Posted 30 October 2013 - 11:07 PM

You don't mention anything about a specific problem or error. Although skimming your code you need to review how if statements and while loops work. Your if statement and while loop assigns a non boolean to a variable then checks to see if it is false? Is there code where you split the csv file? If the data on top is the file I am not sure how well splitting by "," would work honestly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1