OK well since nobody else seems to know I'll do what I can to help.
One thing I might suggest also, is that you edit the custom profile field 'weight' and add this regular expression in the regular expression field:
Code:
^[0-9]*$
This way, if anyone tries to be smart and input characters [a-z] instead of integers [0-9] into your field, the query wont go crazy trying to SUM() a non-integer, and it will give them a stern warning saying that the format they entered is not acceptable.
Still it is up to you.
Now,
Lets see if we can't get this query to run successful. I ran apache on my computer to test the query myself, so I should eventually come up with something which I am positive works...
I am testing it now while I am typing this message.
--- Success so far!
< I am now just doing a few quick last minute troubleshooting for any possible errors you may encounter, so I know in advance what to expect... >
OK no errors encountered on my part. If any of your users have entered non-integer values for weight, it will omit them from the SUM(). I assumed it would error.
Please tell me if this works for you.
PHP Code:
// ### START TEST WEIGHT COUNT ##########################################
$result_allweight = $DB_site->query_first("
SELECT COUNT(*) AS users,
SUM(field7) AS weight
FROM " . TABLE_PREFIX . "userfield
");
// ### END TEST WEIGHT COUNT#############################################
In your template, to call the total weight, you need to use this variable:
Code:
$result_allweight[weight]
It's advisable not to use apostrophes in the variable, eg try to avoid: $result_allweight['weight'] as this will cause a strange Parse Error message in your ACP which you will have to [Continue], although it wont really affect anything. It will just spew some strange eval()'d code error. o.o;
Well, I hope this helps you, if you have any more troubles, I will see what I can do.
Sorry for lengthy delay, it being Xmas and all.