It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

import csv data to database

Moderator: Malcolm

import csv data to database

Postby devppl on Thu Mar 02, 2006 5:33 am

hello everybody,

i have a difficulty,i have a csv file that contains no. of records
seperated by ' ; '.

fields in the record are seperated by ','

i got all record and fields into an array

if there is single record it is stored in database but the problem with multiple record occur


Thanks,
DEVPPL
devppl
 
Posts: 21
Joined: Wed Feb 22, 2006 5:17 am

Postby webmaster on Thu Mar 02, 2006 10:07 am

This is an example of importing a file with 3 columns:

[php]$insert = "INSERT INTO tourneys (date,time,game)
VALUES ('monday','14','lotto')";
mysql_query($insert) or die ("Could not add data to the table");

mysql_query("LOAD DATA INFILE 'http://www.yoursite.com/tourneys.csv' INTO TABLE tourneys FIELDS TERMINATED BY ';'") or die(mysql_error());[/php]
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

not done and i require some thing more

Postby devppl on Tue Mar 07, 2006 5:23 am

hello every body ,

i want to import csv file in that case suppose i have made all script for insertion in database records but the problem is that there is number of files like yahoo,gmail,rediffmail


if that file contains



Name,E-mail Address,Notes,E-mail 2,E-mail 3,Mobile Phone,Pager,Company,Job Title,Home Phone,Home Phone 2,Home Fax,Home Address,Business Phone,Business Phone 2,Business Fax,Business Address,Other Phone,Other Fax,Other Address
Test Name,Test@mail.com,,,,,,,,,,,,,,,,,,


while reading csv files it take all fields in one row

so i want to store first line of the file
like as $Name
$E-mail Address,



like that and for next row i can assign

$Name=$Test Name;


is it possible ,

Please send me reply as early as possible

Thanks
DEVPPL
devppl
 
Posts: 21
Joined: Wed Feb 22, 2006 5:17 am


Who is online

Users browsing this forum: No registered users and 0 guests