Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

PHP Programs

Uploaded by

jonatha98637726
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

PHP Programs

Uploaded by

jonatha98637726
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

PHP PROGRAMS.

Displaying Names into Twenty Times:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>My_Name in 20 Times</title>
</head>
<body bgcolor="gold">
<center>
<strong>
<?php
for ($i=1; $i <=20 ; $i++) {
echo "Jonathan <br>";
}

?>
</strong>
</center>
</body>
</html>

Displaying A in Triangle format:


[AUTHOR NAME]IJONATHAN_AS 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>Loop for AAAA more</title>
</head>
<body bgcolor="silver">
<?php
$rows=12;
for ($i=1; $i <=$rows; $i++) {
for ($j=1; $j <=$rows-$i; $j++) {
echo "";
}
for ($k=1; $k <=1*$i-1; $k++) {
echo "<b>Alice\n</b>";
}
echo "<br>";
}
?>
</body>
</html>

Displaying Hello from 1 to Hello 6:

[AUTHOR NAME]IJONATHAN_AS 2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>Hello in 6-Phases</title>
</head>
<body bgcolor="cyan">
<center>
<?php
$i=1;
while ($i<=6) {
echo "<h3>Hello \n" .$i."</h3>";
$i++;
}

?>
</center>
</body>
</html>

Number Comparision:

<!DOCTYPE html>
<html lang="en">

[AUTHOR NAME]IJONATHAN_AS 3
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>Comparison</title>
</head>
<body bgcolor="bisque"> <center>
<form action="" method="POST">
<div class="memo">
<h1 style="color: black; font-weight: bold; font-style: italic; font-
family: serif; font-size: 0.25in; text-shadow: 1px 1px blue;">
<marquee>
Comparison of numbers
</marquee></h1>
<label>Num1:</label>
<input type="text" name="Num1" value="" step="any"
pattern="[0-9]+" required/>
<br><br>
<label>Num2:</label>
<input type="text" name="Num2" value="" step="any"
pattern="[0-9]+" required/>
<br><br>
<label>Num3:</label>
<input type="text" name="Num3" value="" step="any"
pattern="[0-9]+" required/>
<br><br>
<button type="submit" name="compare">Compare</button>
<br><br>
[AUTHOR NAME]IJONATHAN_AS 4
<style>
button {
color: whitesmoke;
background: black;
font-size: 0.19in;
font-weight: bold;
font-family: monospace;
border-radius: 5px;
}
</style>
</form>
<?php
if (isset($_POST['compare'])) {
$Num1 = $_POST['Num1'];
$Num2 = $_POST['Num2'];
$Num3 = $_POST['Num3'];
$Sum = $Num1+$Num2+$Num3;
if ($Num1>$Num2 && $Num1>$Num3) {
$conclusion = "$Num1 > $Num2 and $Num3";
}
if ($Num2>$Num1 && $Num2>$Num3) {
$conclusion = "$Num2 > $Num1 and $Num3";
}
if ($Num3>$Num2 && $Num3>$Num1) {
$conclusion = "$Num3 > $Num2 and $Num1";
}

[AUTHOR NAME]IJONATHAN_AS 5
if ($Num1==$Num2 && $Num1>$Num3) {
$conclusion = "$Num1 \n = $Num2 but != $Num3";
}
if ($Num1==$Num3 && $Num1>$Num2) {
$conclusion = "$Num1 \n = $Num3 but != $Num2";
}

if ($Num2==$Num1 && $Num2>$Num3) {


$conclusion = "$Num2 \n = $Num1 but != $Num3";
}
if ($Num2==$Num3 && $Num2>$Num1) {
$conclusion = "$Num2 \n = $Num3 but != $Num1";
}

if ($Num3==$Num2 && $Num3>$Num1) {


$conclusion = "$Num3 \n = $Num2 but != $Num1";
}
if ($Num3==$Num1 && $Num3>$Num2) {
$conclusion = "$Num3 \n = $Num1 but != $Num2";
}

if ($Num1==$Num2&&$Num1==$Num3) {
$conclusion = "Both $Num1 \n $Num2 \n and $Num3 are
equal";
}

[AUTHOR NAME]IJONATHAN_AS 6
echo "<h2 class='conclusion'>$conclusion <br> The Sum of
above Numbers is $Sum.</h2>";
}

?>
</div>
</center>
</body>
</html>
<style>
.memo {
background: beige;
border: 6px outset rosybrown;
border-radius: 0.3rem;
width: 55%;
margin: 45px 45px 60px 60px;
box-shadow: 2px 4px 4px 2px blue;
}
label{
color: black;
font-weight: bold;
font-size: 0.2in;
word-spacing: 12px;
letter-spacing: 2px;
font-family: Impact;
}

[AUTHOR NAME]IJONATHAN_AS 7
input[type=text]{
color: black;
background: bisque;
font-weight: bold;
font-size: 0.2in;
word-spacing: 12px;
letter-spacing: 2px;
font-family: sans-serif;
border: 3px groove black;
border-radius: 6px;
}
</style>

Simple Calculator:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>Simple Calculator</title>
</head>
<body>
<center>

[AUTHOR NAME]IJONATHAN_AS 8
<div class="myDiv">
<form method="POST" action="Calculator.php">
<h1 style="color: black; text-shadow: 2px 1px greenyellow;">
<marquee>
Simple Calculator
</marquee>
</h1>
<label for="N1">N1:</label><input type="number" name="N1"
step="any" required/><br><br>
<label for="N2">N2:</label><input type="number" name="N2"
step="any" required/><br><br>
<input type="radio" name="show" value="add" required
><label>Add</label>
<input type="radio" name="show" value="minus" required
><label>Minus</label>
<input type="radio" name="show" value="multiply" required
><label>Multiply</label>
<input type="radio" name="show" value="divide" required
><label>Divide</label>
<input type="radio" name="show" value="modulus" required
><label>Modulus</label>
<input type="radio" name="show" value="power" required
><label>Power</label><br><br>
<button type="submit" name="calculate" title="hold to get
answer">Calculate⇲</button>
<br><br>
</form>
<?php
if (isset($_POST['calculate'])) {
[AUTHOR NAME]IJONATHAN_AS 9
$show = $_POST['show'];
$N1 = $_POST['N1'];
$N2 = $_POST['N2'];
switch ($show) {
case 'add':
$result = $N1+$N2;
break;
case 'minus':
$result = $N1-$N2;
break;
case 'multiply':
$result = $N1*$N2;
break;
case 'divide':
$result = $N1/$N2;
break;
case 'modulus':
$result = $N1%$N2;
break;
case 'power':
$result = $N1**$N2;
break;
}
echo "<h2 class='result'>Result ↣";
echo "$N1 $show $N2 ⇒ $result </h2>";
}

[AUTHOR NAME]IJONATHAN_AS 10
?>
</div>
</center>
</body>
</html>
<style>
.myDiv {
background-image: linear-gradient(12deg,hotpink);
border: 3px ridge pink;
border-radius: 4px;
box-shadow: 2px 4px 2px 4px darkblue;
width: 65%;
margin-top: 1in;
}
label {
color: black;
font-weight: bold;
font-size: 0.25in;
font-style: italic;
font-family: serif;
text-shadow: 1px 1px red;
}
input[type=number] {
color: black;
background: bisque;
font-family: serif;

[AUTHOR NAME]IJONATHAN_AS 11
font-weight: bold;
font-size: 0.25in;
border: 4px outset blue;
border-radius: 0.2rem;
}
button {color: black; background: beige; font-weight: bold; font-
family: serif; font-size: 0.25in; border-radius: 0.2rem}
input[type=radio] {
font-weight: bold;
font-size: larger;
}
</style>

If.. Statement:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>If..else Statement</title>
</head>
<body bgcolor="bisque">
<center>
<div class="myDiv">
<form action="Statement.php" method="POST">
[AUTHOR NAME]IJONATHAN_AS 12
<h1 style="color: blue; text-shadow: 1px 1px magenta; font-
family: serif; font-weight: bold; font-size: 0.25in;">
Enter Marks⇩ To Get Result
</h1>
<label>M1:</label><input type="text" name="M1" step="any"
value="" required/> <br><br>
<label>M2:</label><input type="text" name="M2" step="any"
value="" required/> <br><br>
<label>M3:</label><input type="text" name="M3" step="any"
value="" required/> <br><br>
<button type="submit" name="check">Get_Result</button>
</form>
<?php
if (isset($_POST['check'])) {
$M1 = $_POST['M1'];
$M2 = $_POST['M2'];
$M3 = $_POST['M3'];
$sum = $M1+$M2+$M3;
$average = $sum/3; # $average=($M1+M2+M3)/3
echo "<h2>Sum Is $sum \n and Average Is $average <br> also
agregation is ↧ </h2>";
if ($average==100&&$average>=79) {
echo "<h2> Grade A </h2>";
}
if ($average<=78&&$average>=70) {
echo "<h2> Grade B </h2>";
}
if ($average<=69&&$average>=60) {
[AUTHOR NAME]IJONATHAN_AS 13
echo "<h2> Grade C </h2>";
}
if ($average<=59&&$average>=50) {
echo "<h2> Grade D </h2>";
}
if ($average<=49&&$average>=30) {
echo "<h2> Grade E </h2>";
}
if ($average<=29&&$average>=0) {
echo "<h2> Grade F </h2>";
}
}
?>
</div>
</center>
</body>
</html>
<style>
.myDiv {
background-image: linear-
gradient(120deg,bisque,hotpink);
border: 3px ridge pink;
border-radius: 4px;
box-shadow: 2px 4px 2px 4px darkblue;
width: 65%;
margin-top: 1in;

[AUTHOR NAME]IJONATHAN_AS 14
}
label {
color: black;
font-weight: bold;
font-size: 0.25in;
font-style: italic;
font-family: serif;
text-shadow: 1px 1px red;
}
button {color: black; background:gold; font-weight: bold; font-
family: monospace; font-size: 0.2in; border: 2px red dashed;
border-radius: 0.5rem;}
input[type=text] {
font-weight: bold;
font-size: larger;
}
</style>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<title>Trigonometric Option</title>
[AUTHOR NAME]IJONATHAN_AS 15
</head>
<body>
<center>
<div class="myDiv">
<form action="" method="POST">
<h2 style="color: black; text-shadow: 2px 1px
greenyellow;">Trigonometric Options</h2>
TO:<input type="number" name="N3" title="Enter
Trigonometric Number" required><br><br>
<input type="radio" name="tri" value="cos"
required><label>Cosine</label>
<input type="radio" name="tri" value="sin"
required><label>Sine</label>
<input type="radio" name="tri" value="tan"
required><label>Tangent</label>
<input type="radio" name="tri" value="cotan"
required><label>Cotangent</label>
<input type="radio" name="tri" value="secant"
required><label>Secant</label>
<input type="radio" name="tri" value="cosecant"
required><label>Cosecant</label>
<br><br>
<button type="submit" name="trigonometric">Show
Answer</button>
</form>
<?php
if (isset($_POST['trigonometric'])) {
$N3 = $_POST['N3'];
$tri = $_POST['tri'];
[AUTHOR NAME]IJONATHAN_AS 16
switch ($tri) {
case 'cos':
$Ans = cos($N3);
break;
case 'sin':
$Ans = sin($N3);
break;
case 'tan':
$Ans = tan($N3);
break;
case 'cotan':
$Ans = 1/tan($N3);
break;
case 'secant':
$Ans = 1/cos($N3);
break;
case 'cosecant':
$Ans = 1/sin($N3);
break;
}
echo "<h2 class='Ans'>Answer⇒";
echo "$N3 $tri ⇉ $Ans </h2>";
}
?>
</div><br>
</center>

[AUTHOR NAME]IJONATHAN_AS 17
</body>
</html>
<style>
.myDiv {
background-image: linear-
gradient(12deg,orange,bisque,rebeccapurple);
border: 3px ridge pink;
border-radius: 4px;
box-shadow: 2px 4px 2px 4px darkblue;
width: 65%;
margin-top: 1in;
}
label {
color: black;
font-weight: bold;
font-size: 0.25in;
font-style: italic;
font-family: serif;
text-shadow: 1px 1px red;
}
input[type=number] {
color: magenta;
background: cyan;
font-family: sans-serif;
font-weight: bold;
font-size: 0.2in;

[AUTHOR NAME]IJONATHAN_AS 18
border: 4px red;
border-radius: 2px;
}
button {color: black; background: chartreuse; font-weight: bold;
font-family: serif; font-size: 0.25in}
input[type=radio] {
font-weight: bold;
font-size: 0.3in;
}
</style>

[AUTHOR NAME]IJONATHAN_AS 19

You might also like