Multiple field search using PHP & MySQL
Is it possible or is there an extension to create a mutiple field search using Dreamweaver MX, php and MySQL? For example. Pick a house type (detached, semi etc) then pick the number of rooms, then location etc. Get the idea? I've seen it done in .asp but so far not in php/mySQL. cheers
Comments
...
SELECT * FROM table1 WHERE field1=param1 AND field2=param2 (in case you want BOTH conditions to be true) or
SELECT * FROM table1 WHERE field1="param1" OR field2="param2" (when either condition can be true)
Now, if your data is spreaded over several tables, there is a strong chance that they have been connected with an universal ID-field, in this cas you could join the tables into one logical one in your SQL-statement and use the above method to find from several fields.
SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id
The "id" columns should be of the same type. It's unnecessary to write an SQL primer here, as the MySQL website provides adequate documentation with user comments and tips and there are some fabulous articles on the subject here in the Premium Content as well.
But if there is no "relation" between the tables you want to search from, then there's a way to use a dropdwon menu or a radio group to select the table from which to search.
RE: ...
If you have the fields in the same TABLE in your database...
Sorry, my bad :)
You must me logged in to write a comment.