...

View Full Version : Selecting all Data from one table row.



Atrhick
08-17-2011, 04:14 PM
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

$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?

Fou-Lu
08-17-2011, 04:34 PM
Sure, you sum them: SELECT SUM(price) AS totalPrice FROM lead_partners_pages WHERE partnerid = '$partnerid'

Atrhick
08-17-2011, 05:30 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum