I have a table called mybb_users with a column called totalearnings and another column called Lead
OK I want a php code that will only look at all people (the rows) who have a Lead column that has the letter c in it, and add up every single number in the totalearnings column and give me the total. I only need the total, not a whole list of all the people... and make sure that it only adds up the ppl who have the letter "c" included in the Lead column... thx
EDIT:
so far i got:
<?php
$query = mysql_query("SELECT SUM(totalearnings) FROM 'mybb_users' WHERE Lead LIKE '%c%'");
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$total = $row['SUM(totalearnings)'];
echo "Total Earnings: $" . $total;
}
?>
and it said query was empty.... but it isnt... when i go into the mysql, i select the LIKE %...% option and put c into it, and it displays all of the numbers... so i need it to add it up somehow... i think its the Lead LIKE thing that isnt working
OK I want a php code that will only look at all people (the rows) who have a Lead column that has the letter c in it, and add up every single number in the totalearnings column and give me the total. I only need the total, not a whole list of all the people... and make sure that it only adds up the ppl who have the letter "c" included in the Lead column... thx
EDIT:
so far i got:
<?php
$query = mysql_query("SELECT SUM(totalearnings) FROM 'mybb_users' WHERE Lead LIKE '%c%'");
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$total = $row['SUM(totalearnings)'];
echo "Total Earnings: $" . $total;
}
?>
and it said query was empty.... but it isnt... when i go into the mysql, i select the LIKE %...% option and put c into it, and it displays all of the numbers... so i need it to add it up somehow... i think its the Lead LIKE thing that isnt working
Last edited: