Jump to content

[SOLVED] Importing data problem


harkly

Recommended Posts

I am importing a large csv file with myphpadmin and something is going wrong with the import. I want to pull data from 2 tables but the info in one will not pull unless I edit the info in myphpadmin. When I say “edit” all I do it open it and click Go, I make no changes at all and everthing works fine – well so far.

 

 

Tables,

 

image:

imgid          artid        title                                            date

IMG0221    AR3614  Portrait of a Young Woman                1916

IMG0888    AR3614  Head of a Woman with a Hat              1907

IMG0006    AR1121  A Bedspread On A Chair, At Night        1986

IMG0007    AR1121  Alba In The Studio                            1987

IMG11255  AR2764  Amusing Party in the Open Air              1621

IMG13642  AR2764  Banquet Scene in a Renaissance Hall    1628

IMG11173  AR584    A Burgher of Delft and His Daughter      1655

IMG11352  AR584    The World Upside Down                      1663

 

artist:

artid                fullName

AR3646          Anthonis Mor van Dashorst

AR3614          Amedeo Modigliani

AR584            Jan Steen

AR2764          Dirck Hals

AR1121          Avigdor Arikha

 

 

Here is what prints up before “editing”-

1. IMG0221, Portrait of a Young Woman, 1916, by

2. IMG0888, Head of a Woman with a Hat, 1907, by

3. IMG0006, A Bedspread On A Chair, At Night, 1986, by

4. IMG0007, Alba In The Studio, 1987, by

5. IMG11255, Amusing Party in the Open Air, 1621, by

6. IMG13642, Banquet Scene in a Renaissance Hall, 1628, by

7. IMG11173, A Burgher of Delft and His Daughter, 1655, by

8. IMG11352, The World Upside Down, 1663, by

 

 

This is what prints afterwards -

1. IMG0221, Portrait of a Young Woman, 1916, by Amedeo Modigliani

2. IMG0888, Head of a Woman with a Hat, 1907, by Amedeo Modigliani

3. IMG0006, A Bedspread On A Chair, At Night, 1986, by Avigdor Arikha

4. IMG0007, Alba In The Studio, 1987, by Avigdor Arikha

5. IMG11255, Amusing Party in the Open Air, 1621, by Dirck Hals

6. IMG13642, Banquet Scene in a Renaissance Hall, 1628, by Dirck Hals

7. IMG11173, A Burgher of Delft and His Daughter, 1655, by Jan Steen

8. IMG11352, The World Upside Down, 1663, by Jan Steen

 

 

The steps I take

 

Character set of the file: utf8  -  this is the default

 

I use the CSV using LOAD DATA

 

Fields terminated by ,

Fields enclosed by “

Fields escaped by \

Lines terminated by ;

Column names

Use LOCAL keyword – checked

 

 

This is my code – I have had help in these forums verifying that it works properly.

 

$query="SELECT image.imgid, image.title, image.artid, image.dt, artist.artid, artist.fullName FROM image LEFT JOIN artist ON artist.artid = image.artid";

$result = mysql_query($query) or die(mysql_error());

$count = count(0);

while ($r=mysql_fetch_array($result))

{	

   $title=$r["title"];

   $imgid=$r["imgid"];

   $dt=$r["dt"];

   $artid=$r["artid"];

   $fullName=$r["fullName"];

echo $count++; 
echo ". ".$imgid.", <i>".$title."</i>, ".$dt.", by <a href='artist.php?artid=$r[artid]'>".$fullName."</a><br>";
}


?>


 

 

Does anyone have any ideas? I am open to importing differently if need be. My image file has 20,000 rows and my artist has 4500. I like to be able to modify the Excel file and then save as a CSV file.

 

Link to comment
https://forums.phpfreaks.com/topic/132331-solved-importing-data-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.