Hi All,
I'm trying to write some code to read a CSV file and produce HTML from it. I'm using MAMP to develop the page, but no code at all will display in the browser. I would like the first line of the file to be the header, and then read each line and putting them into paragraphs.
Structure of events.csv
Summer 2010
Event 1^some information
Event 2^some information^more information
PHP Code:
if (($handle=fopen("events.csv","r"))!=FALSE)
{
while (($data=fgetcsv($handle),500,"^"))!=FALSE)
{
if ($row==0)
{
$num=count($data);
row++;
for ($c=0;$c<$num;c++)
{
?><h1> <?php echo $data[$c]; ?></h1>
}
}
else
{
while (($column=fgetcsv($handle1,500,"^"))!=FALSE)
{
$num=count($column);
for ($c=0;$c<$num;$c++)
{
if ($c=0)
{
?>
<h1><?php echo $column[$c]; ?></h1>
<?php
}
else
{
?>
<p><?php echo $column[$c]; ?></p>
<?php
}
}
}
}
}
}
?>
What's wrong? I've tried debugging the code and the page won't display once it enters the while loop. What do I need to do to fix this code?
Cheers,