Skip to content

Instantly share code, notes, and snippets.

@corbanb
Created January 10, 2014 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corbanb/8344720 to your computer and use it in GitHub Desktop.
Save corbanb/8344720 to your computer and use it in GitHub Desktop.
Output CSV data into HTML with this simple script.
<?php
ini_set('auto_detect_line_endings',TRUE);
$handle = fopen("mydata.csv", "r");
?>
<ul>
<?php while ( ($data = fgetcsv($handle, 1000, ",")) !== FALSE ): ?>
<li>
<a href="<?= $data[4] ?>" class="product-container">
<img class="lazy" src="<?= $data[3] ?>" data-original="<?= $data[3] ?>">
<div class="post-details">
<p class="company"><?= $data[2] ?></p>
<h4><?= $data[0] ?></h4>
<p class="price">$<?= $data[1] ?></p>
<div href="#" class="buy-button"></div>
</div>
</a>
</li>
<?php endwhile; ?>
<?php fclose($handle); ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment