I am new somewhat to PHP & MySql.
Can anyone point me in the right direction with filtering a search query using 4 different list menus.
The structure of the query consists of 2 pages. The first page is a list menu for “Make” (car website) the 2nd page consists of the latter and 3 other list menus that will filter the query: “model” “year” “radius” (radius will be distance based on the the users zip code, which will be manually imputed by user)
Obviously I want them to work as independently to one another as much as possible.
All of these columns are within a single table in mySql
This is what I am working with.
$numSql = mysql_query(“SELECT make FROM listings WHERE make = ‘$make’ $limiter”) or die (mysql_error());
$displayNum = 10;
$last = ceil(mysql_num_rows($numSql) / $displayNum);
if ($page < 1) {
$page = 1;
} elseif ($page > $last){
$page = $last;
}
$limiter = ‘limit ‘.($page – 1) * $displayNum . ‘,’ .$displayNum;
$sql = mysql_query(“SELECT make,year,model,listingId,dealerId FROM listings WHERE make = ‘$make’ ORDER BY year $limiter”) or die (mysql_error());
if(mysql_num_rows($sql) < 1) {
echo “<p>There are no listings that match your search criteria. <a href=’index.php’>Back</a></p>”;
} else {
while($row = mysql_fetch_array($sql)) {
$dealer = $row[‘dealerId’];
$list = $row[‘listingId’];
$subSql = mysql_query(“SELECT imgPath FROM images WHERE listingId = ‘$list’ AND mainImage = ‘1’”) or die (mysql_error());
if(mysql_num_rows($subSql) > 0) {
while ($rows = mysql_fetch_array($subSql)) {
$path = $rows[‘imgPath’];
}
echo “<div class=’thumb’>”;
echo “<p>”.$row[‘year’].”</p>”;
echo “<a class=’image’ href=’photos.php?list=”.$list.”&make=”.$make.”&dealer=”.$dealer.”&page=”.$page.”‘>”;
echo “<img src=”pictures/”.$list.”/”.$path.”” height=’100′ width=’150′ alt=” />”;
echo “</a><p>”.$row[‘model’].”</P></div>”;
}
}
}
I have not even attempted yet from the original query. Thanks in Advance!!