i have code opens csv file , loops through every row of data , creates table it.
there specific columns i'd ignore. how change code not display columns?
<?php echo "<table>\n\n"; $f = fopen("users.csv", "r"); while (($line = fgetcsv($f)) !== false) { echo "<tr>"; foreach ($line $cell) { echo "<td>" . htmlspecialchars($cell) . "</td>"; } echo "</tr>\n"; } fclose($f); echo "\n</table>";
if base on indexes of column, example :
<?php echo "<table>\n\n"; $f = fopen("users.csv", "r"); $idscolumnsnotwanted = array(3,4,20); //indexes of columns don't want display while (($line = fgetcsv($f)) !== false) { echo "<tr>"; $numcolumn=0; foreach ($line $cell) { if(!in_array($numcolumn,$idscolumnsnotwanted) echo "<td>" . htmlspecialchars($cell) . "</td>"; $numcolumn++; } echo "</tr>\n"; } fclose($f); echo "\n</table>";
Comments
Post a Comment