note 51511 rejected from function.fgetcsv by betz
| From: | betz@php.net | Date: | Sat, 02 Apr 2005 08:46:38 +0000 |
| Subject: | note 51511 rejected from function.fgetcsv by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-87337@lists.php.net to get a copy of this message | ||
Note Submitter: mmxprocessor
----
Hi everybody!
I have a tip and problem for use getcsv in order to read data from a CSV file and print it making an
HTML table sorting specific data in each table cell, so, check it out below...
Tip for use:
Making table with especific data in each cell
<?php
$filename="yourdatafile.csv";
$table_atributes='class="top10"';
$td_header_atributes='class="verdana_left" width="480"
valign="top"';
$td_image_atributes='rowspan="2" valign="top"';
$td_info_atributes='class="mssans_left" width="480"
valign="top"';
$id = fopen($filename, "r");
while ($data = fgetcsv($id, filesize($filename), "|"))
$table[] = $data;
fclose($id);
echo "<!-- BEGINS TABLE //-->\n";
foreach($table as $row)
{
echo '<table '.$table_atributes.'>
<tr>';
echo '<td '.$td_header_atributes.'><b>'.$row[1].'.
'.$row[2].' - '.$row[3].'</b>
<br>'.$row[4].'/'.$row[5].'/'.$row[6].'<p></td>';
echo '<td '.$td_image_atributes.'><img
src="'.$row[10].'" alt="'.$row[1].'. '.$row[2].' -
'.$row[3].'"></td></tr>';
echo '<tr><td
'.$td_info_atributes.'>'.$row[7].'</td></tr>';
echo '</table>';
echo '<p><br>';
}
echo "\n<!-- ENDS TABLE //-->\n\n";
?>
Problem:
This code reads entire CSV file and creates one HTML table for each line found it.
I want to get only a specific line from the entire CSV File and print it in the same way into the
table.
Someone can help me with this?