Skip to content

Instantly share code, notes, and snippets.

@RoelofWobben
Created May 10, 2023 11:47
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 RoelofWobben/c694c3b0d227af1a5991219c2844fbee to your computer and use it in GitHub Desktop.
Save RoelofWobben/c694c3b0d227af1a5991219c2844fbee to your computer and use it in GitHub Desktop.
<?php
// ONLY FOR TESTING
error_reporting(E_ALL);
$filename = "stock.csv";
//Open csv file for reading
$file = fopen($filename, "r");
$i=0;
if ($file !== FALSE) {
?>
<div class="phppot-container">
<table class="striped">
<thead>
<tr>
<th>Symbol</th></th>
<th>Price</th>
<th>Symbol</th>
</tr>
</thead>
<?php
while (!feof($file)) {
if($i==0) {
$class = "header";
}
$data = fgetcsv($file, 1000, ",");
$i++;
if (!empty($data)) {
?>
<tr class="data">
<td><?php echo $data[0]; ?></td>
<td>
<?php echo $data[2] ?>;"<?php echo $data[1]; ?>
</td>
</tr>
<?php } ?>
<?php
}
?>
</table>
</div>
<?php
}
fclose($file);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment