PHP Code For A Range?

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Dave_Z

Electrifying GuyTop Member
Impact
394
Hi folks,

Well, finally decided to get my feet wet on PHP. But now need a bit of help.

I read about the IF statement and giving it a shot. What I'm trying to do now
is figure out what's the code to do something like this:

1. There's an empty box to fill in with the words like "please enter figure", and
click submit.

2. The code will give a result like "you pay 1% tax" if the figure that's entered
is within a certain range, say, 5,000 to 10,000.

What I can't figure out using the IF statement is what do I put in that'll take
in the figure (like 6,000) and see if it's within a certain numeric range like I've
posted from item 2 above. So far I'm gathering it's something like this below:

if ($figure == 5,000 to 10,000) {
echo "You pay 1% tax";
}

Or something like that. Been racking my brain for the past hour and feel like I
am going on overload.

Any help?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
to get a range you would do something like:-

PHP:
<?php
$figure = 5000;

if ($figure >= 5000 AND $figure <= 10000)
{
	echo 'You pay 1% tax';
}
?>

The if now checks if the figure is greater than or equal too 5000 AND less than or equal too 10000.

If you simply want to check if it is between those but not equal to them then :-

PHP:
<?php
$figure = 5000;

if ($figure > 5000 AND $figure < 10000)
{
	echo 'You pay 1% tax';
}
?>
 
0
•••
You have to specify that IF the value is above 5,000 while the value is below 10,000. Like this:

if($figure > 5000 && $figure < 10000) {
echo "You pay 1% tax";
}

*edit Argh, too slow :)
 
0
•••
Thanks guys!
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back