Click here to Skip to main content
15,920,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Welcome <?php echo $_GET["name"]; ?><br>
Your email address is: <?php echo $_GET["email"]; ?><br>

<?php
if ($_GET["ano"]<=1000) {
    $num=16000;
    echo "Your salary is ₹", number_format($num);
} else if($_GET["ano"]>=1000 || $_GET["ano"]<=2000) {
    $num=35000;
    echo "Your salary is ₹", number_format($num);
}

else {
    $num=50000;
    echo "Your salary is ₹", number_format($num);
}

?>
<form action="$_GETt1.php" method="get">
<input type="submit" value="GO BACK">
</form>


when i input value less than 1000, it gives me right result.

when i enter value more than 1000, less than 2000, it gives me correct answer.

But, if i input more than 2000, it again gives me salary as 35000 which actually lies in 1000 and 2000 segment.

can someone help me?
Posted

Solution: Replace || with and.

I recommend to read http://www.w3schools.com/php/php_operators.asp[^] or any manual about PHP.

If you don't understand why you need to use and, you have to learn Boole algebra
 
Share this answer
 
Comments
CPallini 11-Sep-15 13:42pm    
5.
ppolymorphe is right. However you don't even need the boolean AND there
PHP
if ($_GET["ano"]<=1000) {
    $num=16000;
    echo "Your salary is ₹", number_format($num);
} else if($_GET["ano"]<=2000) {
    $num=35000;
    echo "Your salary is ₹", number_format($num);
}
else {
    $num=50000;
    echo "Your salary is ₹", number_format($num);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900