Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

[HELP] If between X and X echo ?

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

NetworkTown.Net

Account Closed
Impact
2
Hi

Im having some trouble getting this to work. Iv got some numbers and need php to echo text if the varible is anything between these numbers.

20m | echo 1
10m - 20m | echo 2
5m - 10m | echo 3
8k - 1m | echo 4

i cant seem to figer out how this would work in php as the if($a > 100000 < 200000) doesnt work.

anyone got any idea how to do this?

Thanks in advance rep will be added.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
First convert the number to one standard format.
So 8k goes to 8000 or something.

Now I'm guessing if the number is like 7 than it would display 3 & 4?

- Steve
 
0
Close
yeah iv converted them into standard format but just cant get the if < and > right :|
 
0
Close
Something like this possibly?:

PHP:
<?php

$a = '';

if ($a > 8000 AND $a < 1000000)
{
	echo '5';
}
else if ($a > 1000000 AND $a < 5000000)
{
	echo '4';
}
else if ($a > 5000000 AND $a < 10000000)
{
	echo '3';
}
else if ($a > 10000000 AND $a < 20000000)
{
	echo '2';
}
else if ($a > 20000000)
{
	echo '1';
}

?>
 
1
Close
Thanks works perfect, rep added.
 
0
Close
btw, you can also use && for AND and also || for OR. you can also use parenthesis for order of operations like
PHP:
if((($a > 100 && $a < 200) && $loggedin == true) || $a == 0) {
//code if 100 < $a < 200 and user is logged in, or just if $a = 0
}
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back