I am trying to retrieve a row from my csv file.
For example:
//my csv file
Serial No., Name, Type, Category
12345, John, SG, Old
23456, Mary, MY, New
I am trying searching by serial number. What I want to achieve is something like this.
search: 12345
results: 12345, John, SG, Old
I tried using the method below
<?php
//from the previous page of my search bar
$sn = $_POST["sn"];
$result = [];
if (($handle = fopen("gameDirectory.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($data[1] == $sn)
print_r($data);
}
fclose($handle);
}
?>
It is not showing anything after i click search.