Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 12-21-2004, 12:20 AM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No hope in getting this to work eh??? :ermm:
Reply With Quote
  #12  
Old 12-21-2004, 02:18 AM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

field7 contains numbers that you want to add up? Then here is the query that would work.

Code:
   SELECT SUM(field7) AS total
   FROM " . TABLE_PREFIX . "userfield
Reply With Quote
  #13  
Old 12-21-2004, 11:33 AM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Link14716
field7 contains numbers that you want to add up? Then here is the query that would work.

Code:
   SELECT SUM(field7) AS total
   FROM " . TABLE_PREFIX . "userfield
You mean like this?
Code:
// Weight Count
$result_allweight = $DB_site->query_first(" 
   SELECT SUM(field7) AS total
   FROM " . TABLE_PREFIX . "userfield 
"); 
/* 
$result_allweight['total'] 
*/
Still getting the "Array"
Reply With Quote
  #14  
Old 12-22-2004, 11:25 AM
Davey Davey is offline
 
Join Date: Nov 2002
Location: England
Posts: 383
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Using that corrected code (in your last post), you must not output the variable $result_allweight, but you must output the variable
PHP Code:
$result_allweight['total'
see if that works outputting that variable in the template instead.
You can also remove those comments;
PHP Code:
/* 
$result_allweight['total']
*/ 
They were just an instruction to tell you what I said above in this post.
Reply With Quote
  #15  
Old 12-22-2004, 11:46 AM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Davey
Using that corrected code (in your last post), you must not output the variable $result_allweight, but you must output the variable
PHP Code:
$result_allweight['total'
see if that works outputting that variable in the template instead.
You can also remove those comments;
PHP Code:
/* 
$result_allweight['total']
*/ 
They were just an instruction to tell you what I said above in this post.
When I try to add

$result_allweight['total']

to my template I get

Code:
The following error occurred when attempting to evaluate this template:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
Reply With Quote
  #16  
Old 12-22-2004, 11:53 AM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In my FORUMHOME Template i have :
Code:
$header
<center><b>Total Member Weight Loss is :</b> <b><font color="red">$result_allweight</font></b></center>
$navbar
In my Index.php of the forums I have :
Code:
// ### START TEST WEIGHT COUNT ##########################################
$result_allweight = $DB_site->query_first(" 
   SELECT SUM(field7) AS total
   FROM " . TABLE_PREFIX . "userfield 
");
// ### END TEST WEIGHT COUNT#############################################
Hope thats better so you guys understand whats I have going on.. and BTW I can't thank you guys enough for the help...
Reply With Quote
  #17  
Old 12-24-2004, 01:46 PM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I guess I should give up on trying to get this working? :disappointed:
Reply With Quote
  #18  
Old 12-25-2004, 11:17 AM
Davey Davey is offline
 
Join Date: Nov 2002
Location: England
Posts: 383
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.

PS: Merry Xmas all.
Reply With Quote
  #19  
Old 12-25-2004, 04:28 PM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Davey,

I can't thank you enough for not giving up on my problem and making it work.. I just used your code on the site and its working GREAT!

I have one last request if its not to hard to do..

The total weight loss is 2,221 Pounds (See attached image)
The total comes up as "2221" is it hard to have it put in the " , " for the 1,000 mark so that it will show "2,221"?
If its alot more work then I can deal with it staying the way it is but if its easy to place the " , " It would be great.. Thank for everyone's time that has worked on getting this to work for me.. I can't thank you all enough.. and To Davey please check your PM.. Thanks again!!

Crow
Attached Images
File Type: gif working.gif (649 Bytes, 0 views)
Reply With Quote
  #20  
Old 12-28-2004, 10:03 PM
EvilCrow EvilCrow is offline
 
Join Date: Aug 2002
Location: Detroit, Michigan. US
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I guess no one wants to give this one a try! :ermm:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:26 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.05765 seconds
  • Memory Usage 2,283KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_code
  • (5)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete