How can I get the max value from a record set im pulling back, Im creating a table by looping thro the record set.
and im populating a table with thisPHP Code:<?php
$result = mysql_query("SELECT order_code, description, price, postage, quantity FROM tbl_cart WHERE transid='" . $_SESSION['cartnumber'] . "'") or die(mysql_error());
$num_rows = mysql_num_rows($result);
if (!($num_rows))
{
//format all this pretty pretty
die('Your shopping cart is empty.'. mysql_error());
}
?>
PHP Code:<table width="100%" border="1">
<tr><th>Item Code</th> <th>Description</th> <th>Quantity</th> <th>Price</th> <th>Total</th><th>Remove</th></tr>
<?php
while($row = mysql_fetch_array( $result )) {
$amount = $row['quantity'];
$price = ltrim($row['price'],£);
$tamount = ($amount * $price);
$gt = $gt + $tamount;
echo '<td width="10%">'.$row['order_code']. '</td>';
echo '<td width="50%">'.$row['description']. '</td>';
echo '<td width="10%">'. $row['quantity']. '</td>';
echo '<td width="10%">'.$row['price']. '</td>';
echo '<td width="10%">' . '£' . $tamount . '</td>';
echo '<td width="10%"><a href="deleteentryfromcart.php?oc='.$row['order_code'].'&transid=' . $_SESSION['cartnumber'] .'" target="_self">Remove</a></td>';
echo '</tr>';
}
?>
</table>
I need to find the highest value in the postage field, I have found the max() function but im not sure how to incorate it into the loop.
thanks Chris
