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!


All times are GMT. The time now is 03:05 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.01621 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete