I was curious if anyone could help me. I need to write an insert to take data from a csv file to put into a MySQL db. I am not sure know to parse out 5 items of the string at a time i.e. (1,2,3,4,5,1,2,3,4,5,1...etc) so that the five putted items get inserted everytime. Like:
"insert into products (item,price,rate,name,desc) values (1,2,3,4,5)" Then on to the next one and so forth. I am already parsing the file, but not sure if it needs to go into an array or set to vars then done in a loop. Please help! Here is the script so far: <? $filename = "inventory.csv"; $fd = fopen ($filename, "r"); $contents = fread ($fd,filesize ($filename)); fclose ($fd); $delimiter = ","; $splitcontents = explode($delimiter, $contents); $counter = "5"; ?> <br><br> <font color="blue" face="arial" size="4">Database Insert Script</font> <hr> <? foreach ( $splitcontents as $color ) { $counter = $counter+1; echo "<b>Line Item $counter: </b> $color\n<br>"; } ?> <hr> Dustin Wish System Engineer & Programmer INDCO Networks Pres. OSSRI Pres. WTA Arkansas ******************************************************** "Do not go where the path may lead, go instead where there is no path and leave a trail." Ralph Waldo Emerson (1803-1882) *********************************************** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php