
Pixels & Beats
User
Dec 1, 2009, 3:05 AM
Post #7 of 10
(16742 views)
Shortcut
|
|
Re: [chris] Order Results using dropdown
[In reply to]
|
Can't Post
|
|
Hi Chris, Got it all working OK except that I used a different method/code, as I was getting multiple entries for the same make (not your fault as you gave me exactly what I asked for lol!). It took me ages to work out how to do it, but with the help of other posts here on the forum, and your previous reply, I got there :) There is however there is one usability issue I am trying to work round. Make - Model - Colour are all now dynamically populated. However, combinations may not work as each option is not necessarily related to the other. For example there are no Peugeot bikes with the model name of 1098 (that is a Ducati model) Is there a way to populate a list depending on the selection made in the first one. For example if I choose Peugeot then the model list would show only Peugeot models. Here is a copy of the current code I am using. ------------------------------------------------------------------ <?php /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */ require_once "init.php"; list($listingRecords, $listingDetails) = getRecords(array( 'tableName' => 'adverts', 'orderBy' => 'PRICE', )); ?> <?php foreach ($listingRecords as $record): $makeRecords[] = $record['MAKE']; $makeRecords = array_unique($makeRecords); $modelRecords[] = $record['MODEL']; $modelRecords = array_unique($modelRecords); $colourRecords[] = $record['COLOUR']; $colourRecords = array_unique($colourRecords); endforeach; ?> ------------------------------------------------------------------ <select name="MAKE"> <option value="">All</option> <?php foreach ($makeRecords as $record): ?> <option value="<?php echo htmlspecialchars($record) ?>"><?php echo htmlspecialchars($record) ?></option> <?php endforeach; ?> </select> <span class="redhighlight">Model:</span> <select name="MODEL"> <option value="">All</option> <?php foreach ($modelRecords as $record): ?> <option value="<?php echo htmlspecialchars($record) ?>"><?php echo htmlspecialchars($record) ?></option> <?php endforeach; ?> </select> <span class="redhighlight">Colour:</span> <select name="COLOUR"> <option value="">All</option> <?php foreach ($colourRecords as $record): ?> <option value="<?php echo htmlspecialchars($record) ?>"><?php echo htmlspecialchars($record) ?></option> <?php endforeach; ?> </select> <span class="redhighlight">Min Price:</span> <select name="PRICE_min"> <option value="">All</option> <option value="1000">£1000</option> <option value="2000">£2000</option> <option value="3000">£3000</option> <option value="4000">£4000</option> <option value="5000">£5000</option> <option value="6000">£6000</option> <option value="7000">£7000</option> <option value="8000">£8000</option> <option value="9000">£9000</option> <option value="10000">£10000</option> </select> <span class="redhighlight">Max Price:</span> <select name="PRICE_max"> <option value="">All</option> <option value="1000">£1000</option> <option value="2000">£2000</option> <option value="3000">£3000</option> <option value="4000">£4000</option> <option value="5000">£5000</option> <option value="6000">£6000</option> <option value="7000">£7000</option> <option value="8000">£8000</option> <option value="9000">£9000</option> <option value="10000">£10000</option> </select> <span class="redhighlight">Min CC:</span> <select name="ENGINECC_min"> <option value="">All</option> <option value="50">50cc</option> <option value="125">125cc</option> <option value="250">600cc</option> <option value="600">600cc</option> <option value="1000">1000cc</option> </select> <span class="redhighlight">Max CC:</span> <select name="ENGINECC_max"> <option value="">All</option> <option value="50">50cc</option> <option value="125">125cc</option> <option value="250">600cc</option> <option value="600">600cc</option> <option value="1000">1000cc</option> </select> </div> <div class="searchbutton"> <input type="submit" class="searchbutton2" value="" /> </div> </form> <!-- show listings --> <?php foreach ($listingRecords as $listing): ?> <div class="usedbikeblock"> <?php foreach ($listing['uploads'] as $upload): ?> <?php if ($upload['hasThumbnail']): ?> <a href="<?php echo $listing['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" border="0" title="<?php echo $upload['info1'] ?>" alt="<?php echo $upload['info2'] ?>" /></a><br/> <?php break /* only show one image */ ?> <?php endif; ?> <?php endforeach ?> <?php if (!$listing['uploads']): /* if no uploads show this: */ ?> <div class="bikeimage"><br /><br /><b>Photo<br/>Not<br/>Available</b></div> <?php endif; ?> <b><a href="<?php echo $listing['_link'] ?>" class="title"><?php echo $listing['MAKE'] ?> - <?php echo $listing['MODEL'] ?></a></b><br/> <span class="newsheading">Price:</span> £<?php echo number_format($listing['PRICE']); ?><br/> <span class="newsheading">Year:</span> <?php echo $listing['YEAR'] ?><br/> <span class="newsheading">Miles:</span> <?php echo $listing['MILEAGE'] ?><br/> <span class="newsheading">Color:</span> <?php echo $listing['COLOUR'] ?><br/> <span class="newsheading">Engine:</span> <?php echo $listing['ENGINECC'] ?>cc<br/> </div> <?php endforeach ?> <br/> <!-- /show listings --> ------------------------------------------------------------------ Thanks for your help on this. It is very much appreciated :)
(This post was edited by 8bit Gamer on Dec 1, 2009, 8:55 AM)
|