Note that there are some explanatory texts on larger screens.

plurals
  1. POphp - display csv data in tabular format
    text
    copied!<p>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. </p> <pre><code>&lt;?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 "&lt;ul&gt;"; while($row = $pagedResults-&gt;fetchPagedRow()) { //when $row is false loop terminates $row1 = str_replace( ',', "\t", $row ); echo "&lt;li&gt;{$row1}&lt;/li&gt;"; } echo "&lt;/ul&gt;"; //important to set the strategy to be used before a call to fetchPagedNavigation $pagedResults-&gt;setLayout(new DoubleBarLayout()); echo $pagedResults-&gt;fetchPagedNavigation(); ?&gt; </code></pre> <p>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 <a href="https://stackoverflow.com/questions/12023321/grabbing-contents-of-a-mysql-table-and-display-them-in-a-table-on-web-page-pdo">link</a>.</p> <pre><code>while($row = $pagedResults-&gt;fetchPagedRow()) { //when $row is false loop terminates &lt;table&gt; &lt;tr&gt; $row1 = str_replace( ',', "\t", $row ); &lt;td&gt;&lt;?php echo "&lt;li&gt;{$row1}&lt;/li&gt;";?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; } echo "&lt;/ul&gt;"; </code></pre> <p>However, I am not getting output in my screen. Can someone please guide me in the right direction?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload