shop by price

Hello
On my website, I would like to have a shop by price, something like the following

£0.01 - £2.99
£2.99 - £3.99
£3.99 - 6.99
£6.99 - £9.99
£9.99 or more

How would I do that and get the results from the mysql database when click on one of the above price links

something like
[php]$tmp = explode("-", $_POST[‘price’]);
$start = $t[0];
$end = $t[1];
$q = mysql_query(“SELECT * FROM table WHERE price BETWEEN ‘$start’ AND ‘$end’”);

if(mysql_num_rows != 0) {
while($row = mysql_fetch_array($q)) {
// display items here

}
} else {
echo “No items found with in that price range”;
}[/php]

That script assumes that you’re using radio butttons for the price selection, if you’re going to use checkboxes, then you need use a loop to process each selection.

Hello,

Richei, your code needs to be fixed a little.

[php]$tmp = explode("-", $_POST[‘price’]);
$start = $tmp[0];
$end = $tmp[1];[/php]

I think that this is what you meant; tell me if I’m wrong.

Cheers!

yea, thats what ment, thanks. ::slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service