As I mentioned in the previous article, sometimes it can be useful to connect to a CSV file, thus avoiding other conversions. An important aspect is to get results, based on searches, especially if there are many records. The procedure used can be quite simple, as shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
if (!isset($_REQUEST['nume'])) { // Especially helpful at first access, to avoid an error message echo ''; } else { // Search $caut = $_REQUEST['nume']; if (($fp = fopen("angajati.csv", "r")) !== false) { while (($td = fgetcsv($fp)) !== false) { $nume=$td[0]; if($nume === $caut) {echo $td[0] . ' ' . $td[1] . ', ' . $td[2] . '<br>';} } fclose($fp); } } |