Hello forum members,
I am a beginner at programming and at PHP too. My objective is to read a CSV file check the initial two conditions for a match and then forward the user to a link
Here is my CSV file
php,26.06.2011,http://www.google.com
java,26.06.2011,http://www.google.com
This is the code that I've written. My problem is that the code does not read the entire contents of the CSV file. It reads the second line but not the first line. I'm a bit confused could someone help me
<?php
error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "On");
$name_value=$_GET['query'];
$fh = fopen('db.csv', 'r');
$now = date("d.m.Y");
$data=fgetcsv($fh);
$name=$data[0];
$date=$data[1];
$url=$data[2];
while(list($name, $date, $url) = fgetcsv($fh))
{
{
if($name_value == $name AND $date>=$now)
{
header("Location: $url");
exit();
}
else
{
echo "name is $name \t\t name 2 is $name_value<br>";
echo "date is $date \t\t now date is $now<br>";
echo "URL is $url";
}
exit;
}
}
?>