hi,
i am trying to search a database with car parts info in it. The user types a part name with year he/she gets the expected results. sounds simple, but i am having problems. here is how everything is put together [abstract].
mysql
year_from | year_to | make | model | part_name
98 | 04 | honda | civic | COVER PRIMED FRONT
92 | 95 | honda | civic | fender
93 | 96 | honda | civic | engine
the form
<form name=”form” action=”search.php” method=”get”>
<input maxlength=”17″ type=”Text” name=”q”></td>
<input type=”submit” name=”Submit” value=”Search”/>
</form>
php codes [search.php]
<?
mysql_connect (host, username, password);
mysql_select_db(“db”) or die(“Unable to select database”);
$query = “SELECT * FROM parts WHERE make LIKE ‘$q’ ||
model LIKE ‘$q’ || part_name LIKE ‘$q’ || year_from LIKE ‘$q’ || year_to LIKE ‘$q'”;
while ($row= mysql_fetch_array($result)) {
$make = $row[“make”];
$model = $row[“model”];
$part_name=$row[“part_name”];
$year_from = $row[“year_from”];
$year_to = $row[“year_to”];
$quantity=$row[“quantity”];
echo “$row[“model”]<br>”;
…
…
?>
so far, i have been able to ONLY get just by year, or make, or model, or part name, but not a combination. to make matters a bit more complex i am trying to find parts by typing:
“94 civic” ——–> 94 is not inventory but is between year_from and year_to
i should get two results, and print them out. i haven tried more than couple ways but so far have not achieved my goal.
also, i can’t figure out how to get results that fall between the years_from and year_to.
ie.
93 95
92 97
92 96
find 94..
thanks in advance for you help.
sincerely,
fusi0n