Hello.
I am a relative newbie to PHP and have created a form that loads data to a MySQL database. I am now working on simple reporting from that database. I have a form the user can fill out with 5 fields. StartDate, EndDate, Crit1, Crit2, Crit3.
Since the user can put in any combination of criteria I am having problems dynamically building the WHERE clause of the SELECT statement.
The StartDate can be populated singularly without an EndDate so the user is asking just for one day of information or they can ask for a date range by populating both fields. They can also populate any of the other criteria.
Does anyone have any ideas how I can dynamically cycle thru all the fields and build a WHERE clause that incorporates all the fields as applicable?
The form has fields startdate, enddate, IDNumber, Name.
I have assigned all the fields in this manner:
$sdate = $POST['startdate'];
$edate = $POST['enddate'];
$idnum = $POST['IDNumber'];
$name = $POST['Name'];
For example if the user populates startdate and IDNumber then the WHERE clause would only reference those two fields..
I hope I am explaining it correctly, I am quite new to this
ANY HELP would be greatly appreciated!!!