PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Tue Jun 20, 2006 5:44 pm
Hi,i would like to nkow how i can add the values recieved from a query. the query i use is
Code: Select all
$sql = "SELECT * FROM `coffers` WHERE `username`='" . $payee . "' AND `payed`='N'";
i want to add all the values from the values colums which i have already recieved like this:
Code: Select all
while ($array = mysql_fetch_array($result)) {
echo '<br>';
echo '<table width="200" border="1" cellspacing="7" cellpadding="7">';
echo '<th>Offer Name</th>';
echo '<th>Completed By</th>';
echo '<th>Offer Value</th>';
while($array = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo '<tr>';
echo '<td>' .$array['offer_name']. '</td>';
echo '<td>' .$array['username']. '</td>';
echo '<td>$' .$array['value']. '</td>';
}
Robert Plank
Forum Contributor
Posts: 110 Joined: Sun Dec 26, 2004 9:04 pm
Contact:
Post
by Robert Plank » Tue Jun 20, 2006 5:58 pm
Code: Select all
$sumSQL = "SELECT SUM(*) FROM `coffers` WHERE `username`='" . $payee . "' AND `payed`='N'";
$total = mysql_result($sumSQL, 0);
Also why are you nesting 2 identical while loops... you're throwing away the first result in the set if you do it that way.
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Tue Jun 20, 2006 6:57 pm
whoops,im sorry. but thatnks for the help.