When somebody visits this page, the wines are soted by year, but i want the user to have an option to sort the wines by price.
The way in which I have done this myself, is have a form with a select drop down menu where the user can sort by higher or lower prices. The form is submitted to the same page, and the forms are generated again, depending on which option was selected.
Here is my code:
Code: Select all
if (isset($order) && $order == "$lowest"){ ?>
<form name="order" method="post" action="redwine.php">
<select name="order">
<option value="lowest" selected>Lowest Price</option>
<option value="highest">Highest Price</option>
</select>
<input type="submit" value="Sort" class="addwine">
</form>
<?php
$result = mysql_query( "SELECT * FROM sullyvin WHERE wine='red single' ORDER BY price ASC", $link );
} elseif (isset($order) && $order == "$highest"){ ?>
<form name="order" method="post" action="redwine.php">
<select name="order">
<option value="lowest">Lowest Price</option>
<option value="highest" selected>Highest Price</option>
</select>
<input type="submit" value="Sort" class="addwine">
</form>
<?php
$result = mysql_query( "SELECT * FROM sullyvin WHERE wine='red single' ORDER BY price DESC", $link );
}else{ ?>
<form name="order" method="post" action="redwine.php">
<select name="order">
<option value="lowest">Lowest Price</option>
<option value="highest">Highest Price</option>
</select>
<input type="submit" value="Sort" class="addwine">
</form>
<?php
$result = mysql_query( "SELECT * FROM sullyvin WHERE wine='red single' ORDER BY year ASC", $link );
}The page is located at:
http://www.incitodesign.com/sullyvin/redwine.php
if you want to take a look at the page.
can anybody see the reason why this isn't working?