Hi,
I am trying to build a search script to pull vehicle listings from a mySQL database using various criteria.
Right now the script works but I am trying to adjust it to preform a more relevant search with more accuracy.
When i search by year it pulls back cars of that year. When searching model it pulls back vehicles of that model. When I search model and year it pulls back Model and all years instead of the searched years.
All of the options fields are missing from the code and when I add them in, they don't work.
code and urls below:
Query:
http://www.bazonka.com/php_auto/db/auto_search.php
Results: http://www.bazonka.com/php_auto/db/auto_search_list.php
<?php
$user = "demo";
$pass = "user1";
$db = "db_auto";
$link = mysql_connect( "localhost", $user, $pass );
if (! $link)
die( "Couldn't connect to database");
mysql_select_db( $db, $link )
or die ("Couldn't open $db: ".mysql_error() );
$result = mysql_query( "SELECT id, year, make, model, color, askprice FROM main WHERE year='$year' OR make='$make' OR model='$model' OR color='$color' OR trans='$trans' OR type='$type' OR mileage='$mileage'");
while(list($id, $year, $make, $model, $color, $askprice) = mysql_fetch_row($result))
{
echo "<font size=\"1\"><table border=0 align=center width=\"480\"><tr>\n"
."<td align=left width=80><a href=\"showall.php?id=$id\">View Ad</a></td><td align=left width=80>$year</td><td align=left width=80>$make</td><td align=left width=80>$model</td><td align=left width=80>$color<td align=left width=80>$askprice</td>"
."</tr><tr><td width=480 colspan=6><HR size=1 width=480 color=black></td></tr></table></font>\n";
}
mysql_close( $link ); ?>
=============================
the query page is built on the post method.
Any help is greatly appreciated.