MySQL select between dates leaving blank -


i'm trying search.

and there input startdate , 1 finaldate.

but person might not type start or final date or neither...

im trying use:

(data between ".$startdate." , ".$finaldate.") 

leaving blank it's not working, unless put start , final dates.

i wanted if person doesn't type dates, keeps searching rest.

is possible?

==edited per request==

put before sql query:

if(empty($finaldate)) $where = "(data >= ".$startdate.")"; else if(empty($startdate)) $where =  "(data <= ".$finaltdate.")";    else $where = "(data between ".$startdate." , ".$finaldate.")"; 

and change

(data between ".$startdate." , ".$finaldate.") 

with

".$where." 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -