I am trying to create a table of results from a database when information is sent via a form.
the problem I am having is when the form is only part filled in, which I want as an option.
I have 5 fields. Firstname, Lastname, Year, Month and Time.
I want visitors to be able to view results by just 'year' or 'year and month' or 'lastname' or 'firstname and lastname' etc etc....
If I just fill 'year' in on the form the results are blank because it is also searching on the other fields, can I get it to search only on the fields that contain data?
This is my attempted code so far, which carries a syntax error???
$query_rs_Race_Results = sprintf("SELECT mm.firstname, mm.lastname, yr.year,mo.month,t.time
FROM tbllink_memb_month AS t
JOIN tblmonth AS mo ON t.month_id = mo.month_id
JOIN tblyear AS yr ON t.year_id = yr.year_id
JOIN tblmembers AS mm ON t.memb_id = mm.memb_id
WHERE if ('varfname' <> "") : print "firstname='varfname' AND";
end if;
lastname='varlname'", $varfname_rs_Race_Results,$varlname_rs_Race_Results);