Web Analytics Made Easy -
StatCounter Selecting all Data from one table row. - CodingForum

Announcement

Collapse
No announcement yet.

Selecting all Data from one table row.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Sure, you sum them: SELECT SUM(price) AS totalPrice FROM lead_partners_pages WHERE partnerid = '$partnerid'
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment


    • #3
      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

      Comment

      Working...
      X