NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [HELP] If between X and X echo ?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-26-2008, 04:48 PM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



[HELP] If between X and X echo ?


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.
NetworkTown.Net is offline  
Old 08-26-2008, 05:10 PM   #2 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,272
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
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
__________________
I feel old.
iNod is offline  
Old 08-26-2008, 05:13 PM THREAD STARTER               #3 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



yeah iv converted them into standard format but just cant get the if < and > right
NetworkTown.Net is offline  
Old 08-26-2008, 06:04 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Something like this possibly?:

PHP Code:
<?php
????: NamePros.com http://www.namepros.com/programming/507923-help-if-between-x-x-echo.html

$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';
}

?>
Eric is offline  
Old 08-26-2008, 06:38 PM THREAD STARTER               #5 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Thanks works perfect, rep added.
NetworkTown.Net is offline  
Old 08-26-2008, 07:29 PM   #6 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



btw, you can also use && for AND and also || for OR. you can also use parenthesis for order of operations like
PHP Code:
if((($a 100 && $a 200) && $loggedin == true) || $a == 0) {
//code if 100 < $a < 200 and user is logged in, or just if $a = 0

nasaboy007 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 01:09 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger