I have the following problem, can anyone help.
I have a search form that captures:
$track=$POST['track'];
$category=$POST['category'];
$type=$POST['type'];
$artist=$POST['artist'];
$label=$POST['label'];
$issue=$POST['issue'];
I need to be able to check the contents of the form and build the query accordingly, however this is further complicated by the fact that "track" searches 5 database fields (track1, track2, .. to track5), so I need that to be a bracketed (series of OR statements).
According to the inputs I may need to have:
SELECT * FROM datatable WHERE (track1 = '$track' OR track2 = '$track' OR track2 = '$track' OR track4 = '$track' OR track5 = '$track') AND catergory = $category AND issue = $issue
Or
SELECT * FROM datatable WHERE (track1 = '$track' OR track2 = '$track' OR track2 = '$track' OR track4 = '$track' OR track5 = '$track')
Or
SELECT * FROM datatable WHERE catergory = $category
Or
SELECT * FROM datatable
Etc... for all permutations
Short of working out all of the permutations and writing code to cater for each (very bloated code); I cannot work out how to do this....
Has anyone any great ideas?