Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well you'd read the CSV file into a multidimensional array. </p> <p>Consider that each line in the CSV file is now a column (goes up to down instead of left to right). This is called Transposing rows to columns.</p> <p>For a table you'll need to loop through each row, not each column. So you create a loop within a loop as shown here:</p> <pre><code>&lt;table border="0" cellspacing="1" cellpadding="1" class="sortable" border="1"&gt;&lt;caption&gt;Title Here&lt;/caption&gt; &lt;thead&gt;&lt;tr&gt;&lt;th class="header"&gt;Time:&lt;/th&gt;&lt;th class="header"&gt;Value 1:&lt;/th&gt;&lt;th class="header"&gt;Value 2:&lt;/th&gt;&lt;th class="header"&gt;Value 3:&lt;/td class="header"&gt;&lt;th class="header"&gt;Value 4:&lt;/th&gt;&lt;th class="header"&gt;Value 5:&lt;/th&gt;&lt;th class="header"&gt;Value 6:&lt;/th&gt;&lt;th class="header"&gt;Value 7:&lt;/th&gt;&lt;th class="header"&gt;Value 8:&lt;/th&gt;&lt;th class="header"&gt;Value 9:&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt; &lt;?php #read CSV file if (($handle = fopen("data.csv", "r")) !== FALSE) { $mycsv = array(); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) $mycsv[] = $data; fclose($handle); #Find the length of the transposed row $row_length = count($mycsv); #Loop through each row (or each line in the csv) and output all the columns for that row foreach($mycsv[0] as $col_num =&gt; $col) { echo "&lt;tr&gt;"; for($x=0; $x&lt;$row_length; $x++) echo "&lt;td&gt;".$mycsv[$x][$col_num]."&lt;/td&gt;"; echo "&lt;/tr&gt;"; } } ?&gt; &lt;/tbody&gt;&lt;/table&gt; </code></pre> <p>Try that out and let me know if it works.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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