Database > General Database

shop by price

(1/1)

Ian Haney:
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

richei:
something like

--- PHP Code: ---$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";
}
--- End code ---


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.

OpzMaster:
Hello,

Richei, your code needs to be fixed a little.


--- PHP Code: ---$tmp = explode("-", $_POST['price']);
$start = $tmp[0];
$end = $tmp[1];
--- End code ---


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

Cheers!

richei:
yea, thats what ment, thanks. ::)

Navigation

[0] Message Index

Go to full version