/    Sign up×
Community /Pin to ProfileBookmark

list menu query filter for Car Website..Make..Model…Year

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!!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@buildingbrickauthorMar 11.2010 — <?php

if ($_GET['make'] != "") {

$query = "SELECT make FROM listings WHERE make = '$make'";

$result = mysql_query($query);

echo $result;

}

if ($_GET['model'] != "") {

$query = "SELECT make, model FROM listings WHERE make = '$make' AND model ='$model'";

$result = mysql_query($query);

echo $result;

}
Copy linkTweet thisAlerts:
@the-ferretAug 05.2010 — Stumbled across this as was looking to do similar with vehicle make and model database.


http://www.datahostingonline.net/vehicle.php

Old thread i know but added in case it helps, took me ages to find anything on search engines ?
×

Success!

Help @buildingbrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...