webent Posted April 19, 2008 Share Posted April 19, 2008 Ok, I hope this isn't against the rules of the forum, but I've made progress past my last post and asked that it be closed... This isn't a repost... With that said... I'm parsing a csv file, putting it into an array, and printing it for initial testing purposes, but what is happening is that it is repeating the first line of data the same amount of times that there is columns in the file... Can someone please look at my loop and tell me what I'm doing wrong? echo '<table>'; $handle = fopen($file_name, "r"); while (($fields = fgetcsv($handle, 0, ",")) !== FALSE) { $num = count($fields); for ($c=0; $c < $num; $c++) { $category_name = $fields[0]; $category_description = $fields[1]; $manufacturer_name = $fields[2]; $products_quantity = $fields[3]; $products_model = $fields[4]; $products_image = $fields[5]; $products_price = $fields[6]; $products_weight = $fields[7]; $products_price_sorter = $fields[8]; $products_name = $fields[9]; $products_description = $fields[10]; $metatags_title = $fields[11]; $metatags_keywords = $fields[12]; $metatags_description = $fields[13]; echo '<tr>' . '<td>' . $category_name . '</td>' . '<td>' . $category_description . '</td>' . '<td>' . $manufacturer_name . '</td>' . '<td>' . $products_quantity . '</td>' . '<td>' . $products_model . '</td>' . '<td>' . $products_image . '</td>' . '<td>' . $products_price . '</td>' . '<td>' . $products_weight . '</td>' . '<td>' . $products_price_sorter . '</td>' . '<td>' . $products_name . '</td>' . '<td>' . $products_description . '</td>' . '<td>' . $metatags_title . '</td>' . '<td>' . $metatags_keywords . '</td>' . '<td>' . $metatags_description . '</td>' . '</tr>' ; } } fclose($handle); Link to comment https://forums.phpfreaks.com/topic/101810-looping-problem/ Share on other sites More sharing options...
webent Posted April 19, 2008 Author Share Posted April 19, 2008 Nevermind, I got it... Link to comment https://forums.phpfreaks.com/topic/101810-looping-problem/#findComment-520983 Share on other sites More sharing options...
stuffradio Posted April 19, 2008 Share Posted April 19, 2008 Glad you got it! Mind hitting topic solved? Link to comment https://forums.phpfreaks.com/topic/101810-looping-problem/#findComment-521001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.