vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Help Needed (https://vborg.vbsupport.ru/showthread.php?t=78471)

ChrisBaktis 03-20-2005 10:29 PM

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?

ChrisBaktis 03-22-2005 06:05 PM

anyone?

Marco van Herwaarden 03-22-2005 07:04 PM

[sql]SELECT SUM(fieldx) from userfield[/sql]

ChrisBaktis 03-22-2005 08:32 PM

Is there a way for this total to show on one of my pages on the site (home page for example)?

Marco van Herwaarden 03-22-2005 08:37 PM

On any vB powered page (script) you could add a:
PHP Code:

$sum_userfield $DB_site->query("SELECT SUM(fieldx) FROM " TABLE_PREFIX "userfield"); 

Now you can use $sum_userfield in your template or echo it out on another way.

ChrisBaktis 03-22-2005 11:44 PM

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?

Marco van Herwaarden 03-23-2005 03:26 AM

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.

ChrisBaktis 03-23-2005 12:18 PM

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?

Marco van Herwaarden 03-25-2005 07:33 PM

Change that query to:
PHP Code:

$sum_userfield $DB_site->query_first("SELECT SUM(fieldx) as total FROM " TABLE_PREFIX "userfield"); 

Then use $sum_userfield[total] in your template.

ChrisBaktis 03-25-2005 11:06 PM

Thanks!

ChrisBaktis 12-03-2005 02:18 AM

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.

Guest190829 12-03-2005 02:33 AM

What do you mean by messing up the page? Did you put it in a plug-in or are you editing the actual file?

ChrisBaktis 12-03-2005 03:20 AM

I was editing the file - Im very new to 3.5.1 and not sure how to do it as a plug in.

Guest190829 12-03-2005 03:26 AM

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...

ChrisBaktis 12-03-2005 03:31 AM

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.

tnguy3n 12-03-2005 05:15 AM

change the query to:
PHP Code:

$sum_userfield $db->query_first("SELECT SUM(fieldx) as total FROM " TABLE_PREFIX "userfield"); 

I would use forumhome_complete rather than forumhome_start.

In FORUMHOME template, place $sum_userfield in wherever you want to show it.

Marco van Herwaarden 12-03-2005 06:24 AM

The above code is for vB3.0. For 3.5 you would need something like:
PHP Code:

$sum_userfield $vbulletin->db->query_first("SELECT SUM(fieldx) as total FROM " TABLE_PREFIX "userfield"); 


ChrisBaktis 12-03-2005 12:37 PM

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
  • Page Generation 0.01062 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete