Show CSV in Dadatables with php

Show CSV in Dadatables with php

zeranozerano Posts: 2Questions: 1Answers: 0
edited June 2014 in Free community support

Hi,

I've a CSV table, which I want to print as datatable. But the system does not recognize the header (as manu header. It shows only the content)... I tried much different ways with the <thead> tag, but it does not work... Can anyone help?

```php
<?php
$datei = 'example.csv';
echo '

'; $open= fopen($datei, "r"); $zeile = 0; while (($data = fgetcsv($open, 10000, ";"))) { echo '' . "\n"; for ( $x = 0; $x < count($data); $x++) { if ($zeile == 0) echo '' . "\n"; else echo '' . "\n"; } $zeile++; echo ''. "\n"; } fclose($open); echo '
'.$data[$x].''.$data[$x].'

';

<?php > ``` ?>

Answers

  • zeranozerano Posts: 2Questions: 1Answers: 0
    edited June 2014

    Ok, I resolved it:

    ```php
    <?php
    $datei = 'example.csv';
    echo '

    '; $open = fopen($datei, "r"); $zeile = 0; while (($data = fgetcsv($open, 10000, ";"))) { if ($zeile == 0) { echo ''; } elseif ($zeile == 1) { echo ''; } echo '' . "\n"; for ( $x= 0; $x< count($data); $x++) { if ($zeile == 0) { echo '' . "\n"; } else echo '' . "\n"; } $zeile++; echo ''. "\n"; } fclose($open); echo '
    '.$data[$x].''.$data[$x].'

    ';

    <?php > ``` ?>
This discussion has been closed.