vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Calculations (https://vborg.vbsupport.ru/showthread.php?t=197230)

Battle_Ring 11-25-2008 07:24 PM

Calculations
 
Hello All

What i have is a Starting Weight
A Current Weight
And a Goal Weight

What i need is for a way to automatically calculate the difference between starting weight and current weight to be entered into a new field called Total Weight Lost

And then Calculate for % Lost int oa new field % Weight Lost

Any idea how this can be done??

Lynne 11-25-2008 07:36 PM

php?

PHP Code:

$start x;
$current y;
$goal z;
$diff $start $current;
etc


Battle_Ring 11-25-2008 07:38 PM

not sure what that means lol

I want this to all show up in my postbit

A member enters their
Starting Weight
current Weight
Goal Weight

Then it automatically calculates there total weight loss and % Lost and puts it in two other fields automatically

Is there like a code i could enter in my postibit that would Calculate that and display it

Lynne 11-25-2008 07:49 PM

No, there is no automatic vb code you can just enter. You could make new Profile Fields for the users to enter this data (starting, current, and goal), but then you will have to write the code yourself to do the calculations.

Battle_Ring 11-25-2008 07:51 PM

I have the fields added already but dont know how to code the calculations.

IS there somebody out there willing to help me with this. It would be much appreciated

Lynne 11-25-2008 07:58 PM

This may help - Perform simple calculations inside templates! Or, you'll just have to write a simple plugin to do the calculations. You should state what page you are trying to spit the information out on though because it would be done differently depending on where you are using the information.

Battle_Ring 11-25-2008 07:59 PM

i would like it to show in the post bit and profile

Lynne 11-25-2008 08:03 PM

Here's another useful article for putting the fields into the postbit - How To Add Custom Profile Field Information To The Postbit For the profile page, you would use the variable $userinfo instead of $post.

Battle_Ring 11-25-2008 08:07 PM

ive got the fields added tothe psot bit, i just need someone to help with the calculations coding now

Lynne 11-25-2008 08:08 PM

Well, I posted an article about doing calculations in your template, so what have you written out so far? And what is the result you are getting?


All times are GMT. The time now is 12:57 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.01074 seconds
  • Memory Usage 1,729KB
  • 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
  • (1)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