php - how to unset query variable -
in order fetch data database (mysql) appending query depending upon user requirement chooses filters i've given him. @ specific point if condition met, want unset field (submissiondate) set variable before , set new field variable. e.g query is:
$query = "select * table2 date(submissiondate) between '$variablename3' , '$variablename4'"
but if following condition true:
if($variablename8=="approved")
so have append previous query , add
$query = "$query , date(newdate) between '$variablename3' , '$variablename4'"
note appending depending upon conditions met. can't write query again . different fields set different values if condition met have unset submissiondate , set newdate field b/w var3 , var4 , unset previous part was:
date(submissiondate) between '$variablename3' , '$variablename4'
so have neglect submissiondate effect while remain in query. there possible way sort type of problem out ?
please try make query variable conditional.
$query = "select * table2 1=1 , "; if($variablename8=="approved") $query .= "date(newdate) between '$variablename3' , '$variablename4'"; else $query .= "date(submissiondate) between '$variablename3' , '$variablename4'";
or looking else?
Comments
Post a Comment