Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

shop by price

Codes here !

Moderators: macek, egami, gesf

shop by price

Postby ianhaney » Thu Jul 12, 2012 12:54 am

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
ianhaney
New php-forum User
New php-forum User
 
Posts: 27
Joined: Tue May 01, 2012 12:30 pm

Re: shop by price

Postby kyle04 » Mon Jul 16, 2012 4:21 pm

You could have each price "link" as a form :

<form name="prices_1" action="yourpage.php" method=POST>
<input type=hidden name="start_price" value="0.01">
<input type=hidden name="end_price" value="2.99">
input type=submit value="£0.01 - £2.99" name="price_range">
</form>

yourpage.php :

if(isset($_POST['price_range'])) {

$start = $_POST['start_price'];
$end = $_POST['end_price'];

$result = mysql_query("SELECT*FROM TABLENAME WHERE FIELD_PRICE BETWEEN $start AND $end");
while($row = mysql_fetch_array($result)) {

$price = $row['FIELD_PRICE'];
// etc
}
} // isset

Or the price links as request urls :
yourpage.php?start=001&end=2.99
Then just use the mysql query :
$result = mysql_query("SELECT*FROM TABLENAME WHERE FIELD_PRICE BETWEEN $start AND $end");

AndyP
kyle04
New php-forum User
New php-forum User
 
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.