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 ?

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
•••
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
•••
yeah iv converted them into standard format but just cant get the if < and > right :|
 
0
•••
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
•••
Thanks works perfect, rep added.
 
0
•••
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
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: a plain list of your portfolio domains
Your public portfolio page has a new option in the menu next to the sort options. "Domain list" opens a plain page with one domain name...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back