Get Paid to Participate - up to $1 per post!     Twitter     Facebook     Google+
Hosting Discussion
 

forgot password?



Reply


Old
  Post #1 (permalink)   08-02-2005, 02:09 PM
HD Newbie
 
Join Date: Jul 2005
Posts: 26

Status: afcbob is offline
Hello i am learning php just now and am using a training course to learn.But i have a problem am trying to use the && but can't get it to work.
This is the code it say to use:

if (($a > 100) && ($a <2000)) {
echo "number is greater than 100 but less than 2000";
}

i have tried moving the $a values up and down but just can't get this to work.
Please help me out.

if i don't get it soon i will have no hair left at all
 
 
 


Old
  Post #2 (permalink)   08-16-2005, 10:05 AM
HD Newbie
 
Join Date: Jul 2005
Posts: 14

Status: Dark is offline
just add the value of $a

before the if statement then a has a value and the statement can check if its true,

whole thing would look like this

<?php
//value of a, a is equal to 220
$a = '220';

//if a is greater than 100 and less than 2000
if (($a > 100) && ($a <2000)) {

//output number is greater than 100 but less than 2000
echo "number is greater than 100 but less than 2000";

//if the number isnt greater than 100 and less than 2000
} else {

//output, number is less than 100 or greater than 200
echo "number is less than 100 or greater than 2000";
}
?>

ps: added comments to explain the code.

Last edited by Dark : 08-16-2005 at 10:13 AM.
 
 
 
Reply

Thread Tools

New Post New Post   Old Post Old Post
Posting Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Sponsored By: