Cheers, I get:
Query failed (): Unknown column 'searchdate' in 'where clause'
Can you not use the name you set (AS searchdate) in the WHERE clause?
EDIT:
ok, as it doesn't look like you can do that, I'm trying this instead:
$yyyy = substr($var,6,4);
$mm = substr($var,3,2);
$dd = substr($var,0,2);
$date = $yyyy.'-'.$mm.'-'.$dd;
$SDresult=mysql_query("SELECT id, Date FROM TABLENAME WHERE Date = \"$date%\"");
$SDrow=mysql_fetch_array($SDresult) or die("Query failed: " . mysql_error());
$SDnumrows=mysql_num_rows($SDresult);
if ($SDnumrows != 0) {
echo 'Exact Date Found: '.$SDrow['Date'].'<br />';
}
I'm trying to make the users date dd-mm-yyyy match a date in the table (yyyy-mm-dd 00:00:00), but as I don't want the time, i'm trying to use \"$date%\" to say that the date im searching for, starts with the users date.
It just returns 'Query failed:' with nothing else.
Any idea where I'm going wrong?
EDIT2:
I changed:
$SDresult=mysql_query("SELECT id, Date FROM TABLENAME WHERE Date = \"$date%\"");
To:
$SDresult=mysql_query("SELECT id, Date FROM TABLENAME WHERE Date LIKE \"$date%\"");
and now I think it's working.