My query :
$att="select
AttData.Rollno,AttData.Name,AttData.Year,AttData.sec,AttData.".$date."
from AttData where AttData.sec='".$sec."' and AttData.dept='".$dept."'
and AttData.year='".$year."' and AttData".$date."='AB' ";
my Database design view is
my error
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'AttData.sec='A' and AttData.dept='cse' and AttData.year='IV' and AttData'02-07-2016'='AB' ''., SQL state 37000 in SQLExecDirect in C:\wamp\www\sms1.7.16epotdaygen_allyear.php on line 325 select invalid37000
try this ...I added square brackets around $date in two spots
$att="select
AttData.Rollno,AttData.Name,AttData.Year,AttData.sec,AttData.[".$date."]
from AttData where AttData.sec='".$sec."' and AttData.dept='".$dept."'
and AttData.year='".$year."' and AttData[".$date."]='AB' ";