PHP Lab Programs
PHP Lab Programs
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)
else
?>
</center>
OUTPUT
table.html
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;
echo "Chennai";
break;
case "Karnataka":
echo "Bengaluru";
break;
echo "Hyderabad";
break;
case "Telengana":
echo "Hyderabad";
break;
case "Maharashtra":
echo "Mumbai";
break;
default:
?>
</center>
OUTPUT
capital.php