Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
Right basically I have two values that are the same, for arguments sake
$x1 = 200
$x2 = 200
Now i want to use some sort of IF statement or anyother statement you can think of to return a value if $x1 = or is greater than, or less than $x2 by 3
so for instance if $x1 = 198 it would return a vale, if $x = 201 it would return a value, but if $x1 = 190 then it woudnt do you see what im getting at?
I need a value to be return if $x1 is equal to or anywher in between + or - 3 each way of $x2
[Edited on 13-04-2007 by Steve]
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
if there was n OR functionto use with IF i could do it easily but i cant find one??
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
if(($x1 >= $x2-3)) && ($x1 <= $x2+3))
Does that work?
[Edited on 13-04-2007 by aPk]
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
il try it in a sec, is || an equivalent of OR?
|
Rus
Member
Registered: 24th Jan 05
Location: SE London, Kent
User status: Offline
|
yeah, thats flash actionscript though isn't it apk?
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
thats php aswell
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
quote: Originally posted by aPk
if(($x1 >= $x2-3)) && ($x1 <= $x2+3))
Does that work?
[Edited on 13-04-2007 by aPk]
actually thinking about it that wont work as it will need both satisfying to return a value, that would work if the && weere replaced with an OR of some type. Would || work? ie
if(($x1 >= $x2-3)) || ($x1 <= $x2+3))
|
Rus
Member
Registered: 24th Jan 05
Location: SE London, Kent
User status: Offline
|
var a:Number = 200;
var b:Number = 196;
if (a + 3 >= b && a - 3 <= b) {
trace("1");
} else {
trace("0");
}
there you go
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
quote: Originally posted by Steve
quote: Originally posted by aPk
if(($x1 >= $x2-3)) && ($x1 <= $x2+3))
Does that work?
[Edited on 13-04-2007 by aPk]
actually thinking about it that wont work as it will need both satisfying to return a value, that would work if the && weere replaced with an OR of some type. Would || work? ie
if(($x1 >= $x2-3)) || ($x1 <= $x2+3))
No, because it would always evaluate as true
Ie. the if would ask if a number was larger or smaller than a constant which is always true (is a 50 larger or smaller than 100 - true).
And yes, thats PHP - I don't know flash
Rus - thats exactly what I came up with. Should work I'd have thought...
[Edited on 13-04-2007 by aPk]
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
Thinking about it - you want to know if a number is >= or <= to a number by 3. My if statement will return true if so and not if false.
Sorted
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
yeah cheers, iv sorted it and got it to work, but doesnt quite work how id liek so iv abaondoned the idea
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
|
Rus
Member
Registered: 24th Jan 05
Location: SE London, Kent
User status: Offline
|
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
Wonder if someone can help me though actually....
I want to take a date that a user has entered and turn it into a date suitable to insert into MySQL.
The user would enter the date required (ie. 21/05/07) and it needs to be rearranged to read 2007-05-21 0000.
Any quick functions or have I got to split the string several times?
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
use the php date function
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
Will that know what to do with plain text?
Haven't tried it BTW.
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
quote: Originally posted by Steve
il try it in a sec, is || an equivalent of OR?
Yes.
|
Ste L
Member
Registered: 3rd Jul 06
Location: Manchester Drives: 106 16v Rallye
User status: Offline
|
thought about useing "elseif"
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
yes too long winded, done i wanted to anyway
apk
http://uk.php.net/date
|