![]() |
Help Needed
Does anyone know a way to take the numerical value of a custom profile field of all the members and add them up and print it out?
|
anyone?
|
[sql]SELECT SUM(fieldx) from userfield[/sql]
|
Is there a way for this total to show on one of my pages on the site (home page for example)?
|
On any vB powered page (script) you could add a:
PHP Code:
|
in a template would I just need to put '$sum_suerfield' where I want it to show up or do I need to use something like $post?
|
If you make sure the above code is in the script that evaluate the template, and that it is executed before the template is called, then yes.
|
Sorry to be a pain but yes to which one - using $sum_userfield by itself or using it like $post[sum_userfield] ?
My plans for now (while the board is smaller) to put this in the Navigational Bar - I will add your code to the global.php file. Can you tell me what I would need to use based on that info? Anyone? |
Change that query to:
PHP Code:
|
Thanks!
|
Where in the global.php file can I put the above db query? seems no matter where I put it it messes up the page.
|
What do you mean by messing up the page? Did you put it in a plug-in or are you editing the actual file?
|
I was editing the file - Im very new to 3.5.1 and not sure how to do it as a plug in.
|
Well I'm not really sure what your doing but you would put that code in global_start or global_complete. Please note that will run the query on every page...
|
I really only want this on the forum home page.
So to do the plug in can use the: forumhome_start and the only code I would need is to put the above code? All im trying to do is take the total from a custom profile field that all the members have and print out the total on the forum home page. Maybe you can clarify what I need to do. |
change the query to:
PHP Code:
In FORUMHOME template, place $sum_userfield in wherever you want to show it. |
The above code is for vB3.0. For 3.5 you would need something like:
PHP Code:
|
works like a charm - thanks for all the help!
|
All times are GMT. The time now is 12:52 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|