Results 1 to 5 of 5

Thread: Max Function resolved

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Newcastle
    Posts
    260

    Resolved Max Function resolved

    How can I get the max value from a record set im pulling back, Im creating a table by looping thro the record set.

    PHP 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());
            
            }

    ?>
    and im populating a table with this

    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
    Last edited by Chrisio; Mar 23rd, 2005 at 04:35 AM. Reason: Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width