Re: CSV.php question
| From: | Tomas V.V.Cox | Date: | Tue, 04 Jun 2002 10:40:45 +0000 |
| Subject: | Re: CSV.php question | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-1580@lists.php.net to get a copy of this message | ||
"F.Thiel" wrote:
>
> >What is URLink? Could you provide a more wide example?
> >
> >
> >Tomas V.V.Cox
>
> Hello Tomas,
> i do have this link:
> www.something.com/showrow.php?id=234
>
> And this is a CSV example
>
> id,article,category
> 233,art1,cat1
> 234,art2,cat2
> 235,art3,cat3
>
> Now i would like to show first the first [the fields] row and second the
> row 'where id=234'.
> Like this as parsed html:
>
>
> <tr><td>id</td><td>article</td><td>category</td></tr>
> <tr><td>234</td><td>art2</td><td>cat2</td></tr>
>
> Is it possible to do this with your CSV class.
> I hope this is clear enough for you.
>
> I tried to use your example of the CSV.php, but it doesn´t worked for me.
>
What about that (not tested code):
<?php
require 'File/CSV.php';
$file = 'your_csv_file';
$conf = File_CSV::discoverFormat($file);
$i = 0;
while($row = File_CSV::read($file, $conf)) {
if ($i++ == 1) {
row2HTML($row);
continue;
}
if ($row[0] == 234) {
row2HTML($row);
break;
}
}
function row2HTML($row) {
print '<tr><td>'.$row[0].'<...;
}
?>
Tomas V.V.Cox