[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-26-2008, 03:48 PM   #1 (permalink)
Account Closed
 
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
55.39 NP$ (Donate)

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, 04:10 PM   #2 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

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, 04:13 PM   #3 (permalink)
Account Closed
 
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
55.39 NP$ (Donate)

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, 05:04 PM   #4 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Something like this possibly?:

PHP Code:
<?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';
}

?>
__________________
Eric is offline  
Old 08-26-2008, 05:38 PM   #5 (permalink)
Account Closed
 
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
55.39 NP$ (Donate)

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, 06:29 PM   #6 (permalink)
Senior Member
 
nasaboy007's Avatar
 
Join Date: Jul 2005
Location: NJ
Posts: 1,112
1,454.30 NP$ (Donate)

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 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:54 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85