carefree Posted July 28, 2007 Share Posted July 28, 2007 Ive never used a csv file before and im wondering if anyone knows how to get one to link to pictures in a gallery, which uses php coding as it base?? Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 28, 2007 Share Posted July 28, 2007 Without knowing anything about your csv file, or your gallery of pictures, the amount of advice I can offer is minimal. But I can point you in the direction of the fgetcsv() function that can help you parse a csv file - Look it up in the manual. Quote Link to comment Share on other sites More sharing options...
carefree Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks for the reply. Yeah functions are beyond me for the moment, but ive heard you can use sql to dump the csv file into the database like a table, is that true?? I know how to do a table dumb and use myphpadmin I dont really want to mess up my whole site it took months to build. I might get a freelancer to write a guide for me, it looks like one of those tricky things like installing ffmpeg codec ?? :'( Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 29, 2007 Share Posted July 29, 2007 How have you managed to build a site with PHP without any functions?! Using a function in PHP is nothing like installing a codec on your machine, they're hardly comparable! Did you even take a look at the manual page for fgetcsv()? There is a snippet of example code that should get you close to where you want to be! <?php $row = 1; $handle = fopen("test.csv", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); ?> You could pretty much drop everything inside the while() and replace it with an SQL query, matching up the keys in the $data array with the fields in your table. I don't know how to import a csv with phpMyAdmin. Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 I don't know how to import a csv with phpMyAdmin. Select database Select table click SQL choose Insert data from a textfile into table Quote Link to comment Share on other sites More sharing options...
carefree Posted July 29, 2007 Author Share Posted July 29, 2007 I bought the program/site already built, im just modifying it atm. Im still only a php beginner, the coding youve given me is still ova my head atm. Just thought there was an easy way to add associated links to pics, it was worth a try. A table php dump is easy 4 clicks and your done Thanks for the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.