note 51511 added to function.fgetcsv
| From: | mmxprocessor at osu1 dot php dot net | Date: | Sat, 02 Apr 2005 01:34:36 +0000 |
| Subject: | note 51511 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87333@lists.php.net to get a copy of this message | ||
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?
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51511
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51511&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51511&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51511&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51511&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51511&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51511&report=yes
Search -- http://master.php.net/manage/user-notes.php