I am trying, to display some data from a CSV file, and need to show only the 4 first rows. Each row is inside an 'ul'
list. Right now everything shows up, so all ul's are displayed. I tryed to add another 'while' loop but everything got broken.
I'm sure this is easy for someone who is used to code in php. I am learning php right now so I will carefully study the good answer to understand just what changes I need to do. Here is the code:
<?php
$row = 1;
if (($handle = fopen($this->getBaseUrl()."csvfile/csv_test.csv", "r")) !== FALSE) {
echo '<ul>';
$count = 0;
while (($data = fgetcsv($handle, 1000, ",",'"')) !== FALSE) {
$name=$data[0];
$bonus=$data[1];
$start=$data[2];
$end=$data[3];
$brand=strtok($name, " - ");
$count++;
echo
'<li><ul><li><img width="90" height="40" src="'
.$this->getSkinUrl('images/logos/').strtolower($brand).'.jpg" /></li>';
echo '<li>'.$name.'</li>';
echo '<li class="bonus"><strong>'.$bonus.'</strong></li>';
echo '<li><span class="green">Start: '.$start.'</span></li>';
echo '<li><span class="red"><strong>end: '.$end.'</strong></span></li>';
echo '<li class="pdf"><a target="_blank" href="'
.$pdf.'" title=""><img src="'.$this->getSkinUrl('images/icon-pdf.png')
.'"/><br/>PDF</a></li></ul></li>';
?>
<?php
}
echo '</ul>';
fclose($handle);
}
else {
echo "NOPE.";
}
?>