aggiefan
06-08-2007, 02:49 AM
I'm coding a page in a new hack I'm building and am trying to sum a column using a where condition. Here's the code I'm using:
$pledgeamount=$vbulletin->db->query("SELECT SUM(donation_amount) from " . TABLE_PREFIX . "donations where donation_sport='$football'");
$pledge=$pledgeamount['donation_amount'];
Essentially, I want the sum of all values in the donation_amount column where the donation_sport column is football. I just want to display the result -- no other special use for it. I'm getting a "RESOURCE ID #81" when I print $pledgeamount, so thought maybe I had to clean it up and so did the $pledge code part...that just comes up blank.
I've done hacks before for Vbulletin, but never had to use a Sum statement. Is there something special I need to do?
$pledgeamount=$vbulletin->db->query("SELECT SUM(donation_amount) from " . TABLE_PREFIX . "donations where donation_sport='$football'");
$pledge=$pledgeamount['donation_amount'];
Essentially, I want the sum of all values in the donation_amount column where the donation_sport column is football. I just want to display the result -- no other special use for it. I'm getting a "RESOURCE ID #81" when I print $pledgeamount, so thought maybe I had to clean it up and so did the $pledge code part...that just comes up blank.
I've done hacks before for Vbulletin, but never had to use a Sum statement. Is there something special I need to do?