I am new to PHP and I am trying to display the CSV data in my web page with pagination option.This is the code I have so far.
<?php
$names = file('demo.csv');
$page = $_GET['page'];
//constructor takes three parameters
//1. array to be paged
//2. number of results per page (optional parameter. Default is 10)
//3. the current page (optional parameter. Default is 1)
$pagedResults = new Paginated($names, 20, $page);
echo "<ul>";
while($row = $pagedResults->fetchPagedRow()) {
//when $row is false loop terminates
$row1 = str_replace( ',', "\t", $row );
echo "<li>{$row1}</li>";
}
echo "</ul>";
//important to set the strategy to be used before a call to fetchPagedNavigation
$pagedResults->setLayout(new DoubleBarLayout());
echo $pagedResults->fetchPagedNavigation();
?>
I was having issues with commas getting displayed in my output. However, I have resolved using the str_replace function. Now, I wish to show the data elegantly in a tabular format. I tried the below code that I saw in another link.
while($row = $pagedResults->fetchPagedRow()) {
//when $row is false loop terminates
<table>
<tr>
$row1 = str_replace( ',', "\t", $row );
<td><?php echo "<li>{$row1}</li>";?></td>
</tr>
</table>
}
echo "</ul>";
However, I am not getting output in my screen. Can someone please guide me in the right direction?
;to separate fields).