Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,206,173 members, 7,994,983 topics. Date: Wednesday, 06 November 2024 at 06:33 AM

PHP Developers, Please Come In - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / PHP Developers, Please Come In (749 Views)

Developers Please I Need Your Help Urgently / Web Developers Please Help!!! / Web Developers, Please Don't Make The Mistake I Made! (2) (3) (4)

(1) (Reply) (Go Down)

PHP Developers, Please Come In by Akotechonline(m): 9:55pm On Nov 27, 2019
i want the script to echo a statement if the number is between 20-30..
i.e
if($result == "70-100"wink //If the result is between 70 to 100 { echo " You scored A"; }
Re: PHP Developers, Please Come In by wwwmaster: 11:15pm On Nov 27, 2019
$result = 23;
if (($result >= 20) && ($result <= 30)) {
echo "Congrats! You scored : A!";
} else {
echo "Missed, sorry!";
}


You can also use in_array() function

$result = 23;
if (in_array($result, range(20, 30), true)) {
echo "Congrats! You scored : A!";
} else {
echo "Missed, sorry.";
}
Re: PHP Developers, Please Come In by wwwmaster: 11:18pm On Nov 27, 2019
Please note that the 23 I assigned to the variable $result is just for test purpose, normally you should get it from the database or even from simple HTML form submission.
Re: PHP Developers, Please Come In by 2ray4sure: 7:10am On Nov 28, 2019
Akotechonline:

i want the script to echo a statement if the number is between 20-30..

i.e

if($result == "70-100"wink //If the result is between 70 to 100
{
echo " You scored A";
}


Do this
It has been tested. If you need further clarification. Pls contact me .


<?php

if(isset($_POST["submit"])){

$result= $_POST["result"];

if($result <= 39) {echo " Your Grade is F"; return;}

if($result > 39 && $result <= 45) {echo " Your Grade is E"; return;}

if($result > 45 && $result <= 50) {echo " Your Grade is D "; return;}

if($result > 50 && $result <= 60) {echo " Your Grade is C"; return;}

if($result > 60 && $result <= 70) {echo " Your Grade is B"; return;}

if($result > 70 && $result < 101) {echo " Your Grade is A"; return;}

}

?>

Psl Enter Your Result:<br>
<form method="post" action="">


<input type="text" name="result">

<input type="submit" name="submit" value="Check Greade">

</form>
Re: PHP Developers, Please Come In by Akotechonline(m): 8:01am On Nov 28, 2019
2ray4sure:


Do this It has been tested. If you need further clarification. Pls contact me .

<?php
if(isset($_POST["submit"])){
$result= $_POST["result"];
if($result <= 39) {echo " Your Grade is F"; return;}
if($result > 39 && $result <= 45) {echo " Your Grade is E"; return;}
if($result > 45 && $result <= 50) {echo " Your Grade is D "; return;}
if($result > 50 && $result <= 60) {echo " Your Grade is C"; return;}
if($result > 60 && $result <= 70) {echo " Your Grade is B"; return;}
if($result > 70 && $result < 101) {echo " Your Grade is A"; return;}
}
?>
Psl Enter Your Result:<br> <form method="post" action="">

<input type="text" name="result">
<input type="submit" name="submit" value="Check Greade">
</form>

Thanks, I now get the clue bro!
Re: PHP Developers, Please Come In by Akotechonline(m): 8:03am On Nov 28, 2019
2ray4sure:



Do this
It has been tested. If you need further clarification. Pls contact me .


<?php

if(isset($_POST["submit"])){

$result= $_POST["result"];

if($result <= 39) {echo " Your Grade is F"; return;}

if($result > 39 && $result <= 45) {echo " Your Grade is E"; return;}

if($result > 45 && $result <= 50) {echo " Your Grade is D "; return;}

if($result > 50 && $result <= 60) {echo " Your Grade is C"; return;}

if($result > 60 && $result <= 70) {echo " Your Grade is B"; return;}

if($result > 70 && $result < 101) {echo " Your Grade is A"; return;}

}

?>

Psl Enter Your Result:<br>
<form method="post" action="">


<input type="text" name="result">

<input type="submit" name="submit" value="Check Greade">

</form>




i later used ElseIf instead of constantly if statement celebration.
Re: PHP Developers, Please Come In by 2ray4sure: 9:47am On Nov 28, 2019
Good .

The source code and screen shot is available here https://www.naijaitguys.com.ng/Title/simple-grading-system-in-php

You can also leave comment if you have more questions.

(1) (Reply)

Is Blogging Dead On Blogger? (here's What Nobody Is Talking About) / Sulaimansarki Buruku Nairaland / Get Help Managing Your Blog

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.