SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    295
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    if statement in a while loop

    please am trying to do a calculation and am putting a if stament in a while loop but not getting the total price the

    mark up is below


    PHP Code:
       
       $pplresult 
    mysql_query("SELECT * FROM repplac WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
      while (
    $row mysql_fetch_assoc($pplresult)) 
       
    //echo $row['Pquantity'] * $row['Price'];
      
    {
       
    $totalPrices += $row['Tprice'];
        if(
    0.1*$totalPrices <= 50 )
        {
        
    $totalPrice = (0.1*$totalPrices +  $totalPrices);
        }
        else
       {
        
    $totalPrice 50 $totalPrices;
            }
            
      }
      
    //echo "$totalprice";
      
             
    ?> 
    HTML Code:
    <tr>
                    <th>Total Price</th>
                    <th><?php echo $totalprice; ?></th>
                    
                </tr>

  2. #2
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    295
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I HAVE SOLVED IT THANKS

  3. #3
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,095
    Mentioned
    55 Post(s)
    Tagged
    0 Thread(s)
    Why not write this operation into the query?


Bookmarks

Posting Permissions

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