Jump to content

[SOLVED] Reading a CSV File


adam291086

Recommended Posts

I have a script that opens my CSV file and prints the information out onto the screen. Thanks to you guys i got that working in the first place.

 

The problem is that when a column is not filled in, the empty feild is displayed without a border and therefore looks a bit odd. You can see whats happening http://ryedalerumble.co.uk/riders.php here. Here is the code, any suggestions are appreciated.

 

<?php


$filename = "../current/htdocs/excel/CSV/riders.csv";
$id = fopen($filename, "r");

while ($data = fgetcsv($id, filesize($filename),";"))
$table[] = $data;

fclose($id);

echo "<table width=\"100%\" border=\"1\" align=\"left\">\n";

foreach($table as $row)
{
echo "<tr>";
 foreach($row as $data) 
 { 
 $data  = split (",", $data);

  foreach ($data as $newdata)
  {
  echo "<td>$newdata</td>"; 
  }
 }
echo "</tr>\n";
}
echo "</table>\n";
echo "<br />";
?>    

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.