');
print('
Computer electronics |
');
print('Part number | Product | Company | Price |
');
//declare variable to count records
$rowcount = 0;
//get path to file asumming that file located in datafeed folder
$path_to_file="datafeed/filetoread.csv";
//open file for reading "r"
$handle = fopen($path_to_file, "r");
//read file line by line. Enter tab between quotation marks
while (($record = fgetcsv($handle, 1000, " ")) !== FALSE) {
// read number of fields in one record
$numrecords = count($record);
//display all fields for debugging, to know which data is in which field.
for($i=0; $i<$numrecords; $i++)
{
echo $i.":".$record[$i]."
";
}
//read field values in variable
$part_number=$record[0];
$item=$record[1];
$company=$record[2];
$clicklink=$record[3];
$price=$record[4];
//skip the first record since it has field headers only
if($rowcount > 0)
{
//if record has link to item display it in the table row
if($record[3] !="")
{
print(''.$company.' | '.$part_number.' | '.$item.' | '.$price.'
');
}
}
$rowcount++;
}
fclose($handle);
print('');
?>