Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!