![]() |
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?? |
php?
PHP Code:
|
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 |
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.
|
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 |
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.
|
i would like it to show in the post bit and profile
|
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.
|
ive got the fields added tothe psot bit, i just need someone to help with the calculations coding now
|
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?
|
I havent written anything, besides putting my Current Weight, Starting Weight and Goal Weight in my postbit.
I am no good with coding at all, and have no idea what to put in their for the thigns, even after looking at your article:( |
Well, you are going to have to try something in order to see if it will work. You know the equations, right? I can't write any of this for you, you need to write them.
Rewrite these with the correct fields: $diff = $starting - $current $diff = $post[fieldx] - $post[fieldy] ??? Rewrite that using the correct field numbers. Now put it into a condition like the article says: HTML Code:
<if condition="$nextid = $bbuserinfo['userid']+1"></if> Then, if you are going to say "It doesn't work!" you need to post exactly what you wrote and tell us what the result is. |
I entered
<if condition="$post[field13] = $post[field10]-$post[field11]"></if> And nothing else shows up in psotbit at all |
Unless you create a plugin you will have to edit 'class_postbit.php' and insert the following code inside the function 'process_registered_user'
$post['field13'] = $post['field10']-$post['field11']; |
Quote:
HTML Code:
<if condition="$diff = $post[field10]-$post[field11]"> If you need it to be saved somewhere, then you will have to write a plugin to save it to the database. If you just need it spit out in the postbit, then just try what I wrote above. |
All times are GMT. The time now is 05:01 AM. |
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:
|