Hi,
I have a table in MYSQL that has a column named price.
I have multiple other columns in the table that have type, subtype, ssubtype. etc.
eg:
Table Bob
====================================
type | subtype | ssubtype | price
====================================
1 | 2 | 1 | 40
1 | 2 | 2 | 50
1 | 2 | 3 | 60
2 | 3 | 2 | 10
I would like to know how i would go about selecting the lowest and highest price of an item given there may be 2+ versions of that product as above where there are 3 type 1's and the price ranges from 40-60.
That is the info i would like to display in a form just the 40-60.
My initial select statement looks like the below that gathers input from user defined variables.
PHP Code:
$result = mysql_query("SELECT * FROM bob where type='$drop' AND subtype='$drop_2' AND ssubtype='$drop_3'");
and then goes on to display the info:
PHP Code:
echo "<table border='2'>
<tr>
<th>Aprox Lowest Price</th>
<th>Aprox Highest Price</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['price'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
}
?>
<form action="" method="post">
<!--pushing this button resets the search page -->
<input type="submit" name="Details"value="Reset Search" />
</form>
</body>
</html>
=======================================
What this produces is just a list like the following:
Aprox Lowest Price | Aprox Highest Price
$40.00 | $40.00
$50.00 | $50.00
$60 | $60.00
but what i want is:
Aprox Lowest Price | Aprox Highest Price
$40.00 | $60.00
Hope someone can help out as i'm new to this..
ps I want to then go on and provide a button that shows some of the other fields of the initial user defined variables if the user wants to know ho can supply the product type.