hello, I have a large csv file and I want to get data from there. I found that script : <?php $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { 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); } ?> PHP: My csv file contain this : PRODUCT and AFFILIATE_CODE(url of affiliate). (ex . : Laptop Lenovo,http:// affiliatecode . com / abcd123) Now I want to make the script to print like this : PRODUCT Is that possible ? Thank you.
The lines in your csv file have the form: PRODUCT,AFFILIATE_CODE . So, on the script you posted, with the for loop you have for each line: $data[0] is the product and $data[1] is the url. In order to echo this as a link you have to add the following after for loop: echo '<a href="'.$data[1].'">'.$data[0].'</a>'; Code (markup): You can also remove the $row counter and the line that echos the number of fields in each line if you don't need them.
Yes, that is want I want, I eliminated the lines that I don't need them. THank you very much for the explanation.