I've built a search form in essence, where the form has several variables to be passed to the select statement. There's a uniqueID, a typeID and two date fields where a user can search between the two dates. THe form works fine if only searching on either of the IDs, and it works fine if searching between two dates, but when I put them all together in the select statement, none of them work. I'm sure it's just a grammar thing, but I don't know the answer. I was hoping it was going to be something like this: (where $from and $to were assigned values from the form - this works, by the way)

SELECT * FROM Res WHERE (RID LIKE ? OR Type LIKE ? OR (DateField BETWEEN '$from' AND '$to')) ORDER BY RID

I don't think that is true but the only way to know for sure is to try it out. Your script would need to make sure that some data is supplied either a RID or Type or if those are blank then make sure $from and $to is supplied. I see you use ? in the RID or Type but why not for the DateField?