0% found this document useful (0 votes)
35 views6 pages

PHP Lab Programs

Uploaded by

Man m
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)
35 views6 pages

PHP Lab Programs

Uploaded by

Man m
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/ 6

PHP Practical Programs(+2 CS and CA):

Multiplication Table Using PHP


AIM

Design a Webpage using PHP to accept a number and display its multiplication table up to 12 . The HTML page
should contain a text box and submit button

SOURCE CODE

table.html

<html>
<head>
<title>Multiplication Table</title>
</head>
<body>
<center>
<form method="post" action="table.php">
<h4>Enter No:</h4>
<input type="text" name="num">
<input type="submit" value="Get Table">
</form>
</center>
</body>
</html>

table.php

<center>

<?php

$num = $_POST['num'];

if($num<=12)

for ($i=1; $i<=10; $i++)

$mul = $i* $num;

echo "$i*$num= $mul<br>";

else

Prepared by MOHAMMED ASHRAF, KYHSS Athavanad, Malappuram(9947819745) Page 1


{

echo "Invalid Entry!";

?>

</center>

TAGS & ATTRIBUTES

Tag Attribute Value


FORM method post
action table.php
INPUT Type Text
Name num
Type submit
Value Get Table

OUTPUT

table.html

Prepared by MOHAMMED ASHRAF, KYHSS Athavanad, Malappuram(9947819745) Page 2


table.php

Prepared by MOHAMMED ASHRAF, KYHSS Athavanad, Malappuram(9947819745) Page 3


State and Capital Using PHP
AIM

Design a Webpage using PHP to select a State from combo box and display its capital

SOURCE CODE

state.html

<html>
<head>
<title>State and Capital</title>
</head>
<body>
<center>
<form method="post" action="capital.php">
<h4>Select a State:</h4>
<select name="list">
<option>Kerala
<option>Tamilnadu
<option>Karnataka
<option>Andhra Pradesh
<option>Telengana
<option>Maharashtra

</select>
<input type="submit" value="Show">
</form>
</center>
</body>
</html>

capital.php

<center>

<?php

$list = $_POST['list'];

switch($list)

case "Kerala":

echo "Thiruvananthapuram";

break;

Prepared by MOHAMMED ASHRAF, KYHSS Athavanad, Malappuram(9947819745) Page 4


case "Tamilnadu":

echo "Chennai";

break;

case "Karnataka":

echo "Bengaluru";

break;

case "Andhra Pradesh":

echo "Hyderabad";

break;

case "Telengana":

echo "Hyderabad";

break;

case "Maharashtra":

echo "Mumbai";

break;

default:

echo "Invalid Selection";

?>

</center>

TAGS & ATTRIBUTES

Tag Attribute Value


FORM method post
action capital.php
SELECT name list
OPTION
INPUT Type submit
Value Show

OUTPUT

Prepared by MOHAMMED ASHRAF, KYHSS Athavanad, Malappuram(9947819745) Page 5


state.html

capital.php

Prepared by MOHAMMED ASHRAF, KYHSS Athavanad, Malappuram(9947819745) Page 6

You might also like