Searching with MySql, almost got it
Posted: Tue Feb 05, 2008 5:59 pm
Ok so i have a site where you can search business's that sign up. I have 7 different fields to search by. Right now this is my query that runs when you submit the form.
I want it to only filter fields that the user selects from. And if they select more that one field it combines them and filters acordingly. I have the website online but dont want to post the link publicly, if you wish to see the site to get a better idea just say so and i will PM you the link.
This query isn't right but its the closest i could get it to being right. This is my first search script so any help will be great! If you need me to post more code just ask.
Thanks
Code: Select all
// Build SQL Query
$query = "SELECT * FROM ida_business WHERE
industry LIKE '%$tindustry%' OR
region LIKE '%$tregion%' OR
range LIKE '%$trange%' OR
flow LIKE '%$flow%' OR
abs LIKE '%$abs%' OR
sale LIKE '%$tsale%' OR
price LIKE '%$tprice%'
ORDER BY region ASC";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
This query isn't right but its the closest i could get it to being right. This is my first search script so any help will be great! If you need me to post more code just ask.
Thanks