Jump to content

Help with a simple calculation?


Go to solution Solved by possien,

Recommended Posts

Hi Guys,

 

I'm just starting to work with Fabrik & Joomla, and need help with a some custom calculation.

 

Quick question regarding two drop down boxes I am creating a form for past pupils of a school.
 
First drop down box is called 'Year of Leaving' {member_app_year_out} and offers options from '1930' right through to '2014' (lots!).
 
Second drop down box is called 'Membership Type' {member_app_type} and offers two options 'Full Membership £20' and 'Reduced Membership £10'.
 
I want the second drop down box (Membership Type) to be dependant on the selection from the first drop down box. The rule is that 'If you have left the school within the past 7 years, you qualify for a Reduced Membership of £10'. So I want users to select e.g. 2008 and only see 'Reduced Membership', and users who select e.g. 2001 to only see 'Full Membership'. 
 
This also needs to update each year. 
 
How can I do this? Something like if {member_app_year_out} = '(now)' - 7 
 
Apologies for my lack of programming knowledge, I'm learning.
 
Thanks in advance,
 
J
Link to comment
https://forums.phpfreaks.com/topic/286115-help-with-a-simple-calculation/
Share on other sites

  • Solution

As Barand indicated, let your calculation take care of the fee.  Getting the year from their input you could use something like:

<?php
$years =  strtotime('-8 years');
$ref_date = date('Y', $years);
echo '<br />';
echo $ref_date.'<br/>';
$date_left = 2000; //example date from the form
echo $date_left. '<br />';
if($date_left > $ref_date){//if less than 8 years it must be 7 or less
$membership = 10;}// if less than 8
else $membership = 20;//if more than 7
echo $membership;
?>

Use the $membership as the fee.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.