I own an rpg and want to add up all the levels of the users monster and get an end number.
So I narrowed it down for one user and works great.
$_SESSION['username'] = "smbisme";
$query = "SELECT belongsto, SUM(level) FROM user_pokemon WHERE `belongsto` = '".$_SESSION['username']."' ";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo $row['belongsto'];
echo "". $row['SUM(level)'];
echo "<br />";
}
Now, that shows and works for the user 'smbisme' but now I want to do it for all users.
So I try and take the where out like so.
$query = "SELECT belongsto, SUM(level) FROM user_pokemon ";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo $row['belongsto'];
echo "". $row['SUM(level)'];
echo "<br />";
}
But then for some reason i am only getting the highest result ( 1 result ) i would like to do what i did for the 1 user but grab all of the results instead of just the one user.