I have a server side csv table. I want to apply a filter from my html page and see the see the filtered table on the html page;
My HTML code
<!DOCTYPE html>
<html lang="en">
<head>
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <meta charset="utf-8">
  <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
  <meta name="dcterms.created" content="Wed, 30 Jun 2021 12:21:08 GMT">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <title></title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>
  <!-- Start of FORM -->
  <form method="post" action="w3.php">
    <input type="text" name="fname" value=""> <input type="submit" name="submit" value="submit">
  </form><!-- End of FORM -->
</body>
</html>
and the php code
<?php
$str = $val = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    $val = $_POST['fname'];
    if (($file_handle = fopen("ratingsx.csv", "r")) !== false)
    {
        $row = 0;
        $str .= '<table>';
        while (($data = fgetcsv($file_handle, 1024, "|")) !== false)
        {
            $row++;
            if ($data[0] != $val && $row > 1) continue; // *** skip rows without '34' ***
            $str .= '<tr>';
            foreach ($data as $key => & $value)
            {
                $str .= "<td valign='top'>$value</td>";
            }
            $str .= '</tr>';
            $str .= '<tr><td><br></td></tr>';
        }
        $str .= '</table>';
        fclose($file_handle);
        echo $str;
    }
}
?>
The result $str I need to be displayed as a table on the html page. How can I pass it back?. Can anyone help me please?
(This is a reworked question)
 
    