Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selecting all Data from one table row.

    Hello guys I am pretty new to PHP/MYSQL. what I want to do is select all of the price data from the table and display them as a total number.

    PHP Code:
    <?php 

    $query2 
    "SELECT * ";
    $query2 .="FROM lead_partners_pages ";
    $query2 .="WHERE partnerid = '$partnerid'";
    $result_set2 mysql_query($query2);
    $row2 mysql_fetch_array($result_set2);

    ?>
                                               
       <div class="FRight totalprice">
       <?php echo "$".$row2["price"]?>
       </div>

    With the above code I am only getting the price from the first row, I want all of the price fro all of the rows added together. is this possible?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Sure, you sum them: SELECT SUM(price) AS totalPrice FROM lead_partners_pages WHERE partnerid = '$partnerid'

  • #3
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Sure, you sum them: SELECT SUM(price) AS totalPrice FROM lead_partners_pages WHERE partnerid = '$partnerid'
    Thank you very much Fou-Lu it worked out for me perfectly


  •  

    Posting Permissions

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