Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
how import rows from csv file into php html table then add search functionaly with javascript?

I have a CSV file that contains books, the columns in it are:

book_id,name, date_published

it looks like this for example

I need to put this data into an HTML table using PHP, then use javascript to add a search function, that makes it so that if the rows match with the input only then will the table be visible?

I'm completely stumped and would appreciate an easy understanding of the solution!

well I tried to import the CSV file in PHP but I can't seem to get it into an array I tried other methods some got me to the javas cript bit but nothing successful

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can open your CSV file and display it in a table as follows:

<?php
// Open the CSV file
$fcsv = fopen( 'filename.csv', 'r' );
// Get header row
$row = fgetcsv( $fcsv );
// Output start of table & header row
?>
<table>
  <thead>
    <tr>
      <td><?= $row[0] ?></td>
      <td><?= $row[1] ?></td>
      <td><?= $row[2] ?></td>
      <td><?= $row[3] ?></td>
      <td><?= $row[4] ?></td>
      <td><?= $row[5] ?></td>
      <td><?= $row[6] ?></td>
    </tr>
  </thead>
  <tbody>
<?php
// Loop through rest of rows in CSV
while ( ( $row = fgetcsv( $fcsv ) ) !== false )
{
?>
    <tr>
      <td><?= $row[0] ?></td>
      <td><?= $row[1] ?></td>
      <td><?= $row[2] ?></td>
      <td><?= $row[3] ?></td>
      <td><?= $row[4] ?></td>
      <td><?= $row[5] ?></td>
      <td><?= $row[6] ?></td>
     </tr>
<?php
}
?>
  </tbody>
</table>

For the Javascript filtering, you should look at the DataTables JavaScript plugin... it's very simple to set up (see examples on the website) and can search, order & filter data in a variety of ways depending on your needs.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda