Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently trying to modify a line of PHP Code and could do with some assistance.

if ( !empty( $fields['12']['value'] ) && '13-18 Years Old (Monthly) - £2' == $fields['12']['value'] ) { $url = 'http://members.link.com';

I know this is obviously "If field 12 is not empty & if the value is '13-18 Years Old (Monthly) - £2' then goto http://members.link.com

I copied this from the companies forum.

However, I want to add in another condition to this so it becomes

If field 12 is not empty AND if the value of field 12 is '13-18 Years Old (Monthly) - £2' AND the value of field 19 is "Direct Debit" then goto http://members.link.com

Can someone show me where I should be putting the extra && condition?

What I have tried:

Im new to this. So have gotten this far but need assistance with further syntax
Posted
Updated 2-Jul-18 5:36am

I would suggest something along these lines:

if (( !empty( $fields['12']['value'] ) && '13-18 Years Old (Monthly) - £2' == $fields['12']['value'] ) && $fields['19']['value'] == 'Direct Debit')  { $url = 'http://members.link.com';


When building logic constructs like this, it helps to break them down before trying to code them. Start with the smallest and work your way backwards:

Field 19 = 'Direct Debit'

AND...

Field 12 isn't blank AND equals '13-18 Years Old (Monthly) - £2'

Then build it in reverse order.

That might help. (Not 100% on the syntax, it's been a while since I've done PHP.)
 
Share this answer
 
if ($field[12] != null && $field[12][value] == (13-18 years old) && $field[19][value] == ("direct debit"))
{
$url = "http:/members.link.com"
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900