Professional Documents
Culture Documents
Guru Gobind Singh Indraprastha University: Sector - 16 C, Dwarka, Delhi, India
Guru Gobind Singh Indraprastha University: Sector - 16 C, Dwarka, Delhi, India
QUE .1- WAP to print Welcome message along with your name.
<html>
<head>
<title>hello message</title>
</head>
<body>
</form>
<br><br>
Mehak(02016702018)
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['name'];
echo"welcome $a" ;
?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .2- WAP to calculate simple interest, input enter by the user.
<html>
<head>
<title>simple interest</title>
</head>
<body>
Mehak(02016702018) <BR><BR>
Rate <br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$principle = $_GET['p'];
$rate = $_GET['r'];
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
$time = $_GET['t'];
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .3- WAP to calculate area of a rectangle, input enter by the user.
<html>
<head>
</head>
<body>
Mehak(02016702018)
<br><br>
length <br>
breadth<br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['len'];
$b = $_GET['bre'];
$c = $a * $b ;
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo $c;
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .4- WAP to calculate the parameter of a circle, input enter by the
user.
<html>
<head>
</head>
<body>
Mehak(02016702018)
<BR><BR>
radius <br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['rad'];
$c = $a * 3.14*2;
echo $c;
?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .5- WAP to convert the temperature into ˚F to ˚C, input enter by
the user.
<html>
<head>
<title>fahrenheit to celcius</title>
</head>
<body>
Mehak(02016702018)<BR><br>
Temperature in fahrenheit<br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['fah'];
$b=($a-32)*5/9;
?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .6- WAP to check the number whether it is prime or not, input
enters by the user.
<html>
<head>
</head>
<body>
Mehak(02016702018) <br><BR>
<form method="post">
</form>
</body>
</html>
<?php
if($_POST)
$n = $_POST['n'];
for($i=2;$i<=$n-1;$i++)
if($n%$i==0){
$value=True;
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
else{
}}
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .7- WAP to print the odd number series, input enter by the user.
<html>
<head>
</head>
<body>
Mehak(02016702018)<BR><br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['len'];
$n = 2;
$i = $a * $n;
echo "$j".",";
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .8- WAP to generate the odd & even number series, the range
input by the user.
<html>
<head>
</head>
<body>
Mehak(02016702018) <BR><BR>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['len'];
$n = 2;
$i = $a * $n;
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo"<br>";
} }
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .9- WAP to generate the series which divisible by 9, the range
input by the user.
<html>
<head>
</head>
<body>
Mehak(02016702018) <BR><BR>
</form>
</body>
</html>
<?php
if(isset($_GET['sub']))
$a = $_GET['len'];
$n = 9;
$i = $a * $n;
echo "$j".",";
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>armstrong</title>
</head>
<body>
Mehak(02016702018)<br><br>
enter number<br>
</form>
</body>
</html>
<?php
function arms($number)
{ $sum= 0;
$x= $number;
while($x!=0)
{ $rem= $x % 10;
$x= $x/10; }
if($number==$sum)
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
return 1;
else
return 0; }
if(isset($_GET['sub'])){
$number=$_GET['num'];
$flag= arms($number);
if($flag==1)
Else
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .11- WAP to find the factorial of a number, input enter by the
user.
<html>
<head>
<title>factorial</title>
</head>
<body>
Mehak(02016702018) <br><BR>
</form>
</body>
</html>
<?php
if(isset($_GET['submit']))
$fact=1;
$n=$_GET['n'];
echo"Factorial of $n is = <BR><BR>";
for($i=1;$i<=$n;$i++){
$fact=$fact*$i;
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>electricity </title>
</head>
<body>
Mehak(02016702018)<br><br>
</form>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
</body>
</html>
<?php
if(isset($_GET['sub']))
$prev = $_GET['pre'];
$cur = $_GET['cur'];
$bill = '';
{$bill = $consumed * 1; }
elseif($consumed>500)
else
{echo"invalid value";}
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .13- WAP to print the fabonnaci series, input range entered by
the user.
<html>
<head>
<title>fabonacci</title>
</head>
<body>
Mehak(02016702018)<BR><BR>
enter number<br>
</form>
</body>
</html>
<?php
if($_GET)
function Fibonacci($n)
$num1= 0;
$num2= 1;
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo ' '.$num1;
$num1= $num2;
$num2= $num3;
$counter= $counter+1;
$number = $_GET['num'];
$n = $number; Fibonacci($n);
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .14-WAP to check the year value whether it is leap year or not,
input enter by the user.
<html>
<body>
Mehak(02016702018)<br><br>
</form>
</body>
</html>
<?php
if( $_POST )
if(!is_numeric($year))
return; }
else
?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<body>
Mehak(02016702018)<br><br>
<form>
<h4>Student_1 info</h4>
<h4>Student_2 info</h4>
<h4>Student_3 info</h4>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<h4>Student_4 info</h4>
<h4>Student_5 info</h4>
<input type="submit" name="submit" value="calculate marks of 5 student" placeholder = "Please enter the
button">
</form>
</body>
</html>
<?php
@$number3=$_GET['number3']; @$number4=$_GET['number4'];@$number5=$_GET['number5'];
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
@$number8=$_GET['number8']; @$number9=$_GET['number9'];@$number10=$_GET['number10'];
@$number23=$_GET['number23'];@$number24=$_GET['number24'];@$number25=$_GET['number25'];
$student = array(
),
),
),
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
),
//print_r($percentage);
$keys = array_keys($student);
if(strpos($value, "%"))
calcGrade($value);
echo "<br>}<br><br>";
function calcGrade($num) {
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
else
?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<body>
Mehak(02016702018) <br><br>
Enter number<br><br>
</form>
</body>
</html>
<?php
if($_POST){
$number= $_POST['number'];
function factorial($number) {
if ($number < 2) {
return 1;
} else {
} }
echo factorial($number);
}?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .17- WAP to calculate the sum of digits using function, input
entered by the user.
<html>
<body>
Mehak(02016702018)<br><br>
</form>
</body>
</html>
<?php
if($_GET){
function sum($num) {
$sum = 0;
$sum += $num[$i];
return $sum;
// Driver Code
$num = $_GET['numb'];
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo sum($num);
}?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>patterns</title>
</head>
<body>
Mehak(02016702018)<br><br>
enter range<br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub'])){
$a=$_GET['ran'];
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
for($i=1;$i<=$a;$i++)
for($j=1;$j<=$i;$j++)
echo "<br>";
}?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>patterns</title>
</head>
<body>
Mehak(02016702018)<br><br>
enter range<br>
</form>
</body>
</html>
<?php
if(isset($_GET['sub'])){
$a=$_GET['ran'];
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo ' ';
echo '*';
echo '<br>';
}?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<body>
Mehak(02016702018)<br><br>
<form>
Enter a number :
</form>
<?php
@$number1=$_GET['number1'];
echo " ";
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo "*";
echo "<br>";
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<body>
Mehak(02016702018)<br><br>
<form>
Enter a number :
</form>
<?php
@$number1=$_GET['number1'];
if ($number1%2==0)
$number1 = $number1-1;
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo " ";
echo "<br>";
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>patterns</title>
</head>
<body>
Mehak(02016702018)<br><br>
enter range<br>
</form>
</body>
</html>
<html><body><center>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<?php
if(isset($_GET['sub'])){
$a=$_GET['ran'];
for($i=0;$i<=$a;$i++)
{ for($k=$a;$k>=$i;$k--)
for($j=1;$j<=$i;$j++)
echo "<br>";
for($i=$a-1;$i>=1;$i--)
for($k=$a;$k>=$i;$k--)
for($j=1;$j<=$i;$j++)
echo "<br>";
?>
</center>
</body>
</html>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>patterns</title>
</head>
<body>
Mehak(02016702018)<br><br>
enter range<br>
</form>
</body>
</html>
<center>
<?php
if(isset($_GET['sub']))
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
$a=$_GET['ran'];
{ echo" "; }
{ echo"$j"; }
{ echo"$j"; }
echo"<br>";
} }
?></center>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .24- WAP to build a connection with MySQL server and create a
database name as mydb.
<html>
<body>
Mehak(02016702018)<br><br><br>
</body>
</html>
<?php
$servernsme = "localhost";
$username = "root";
$password = "";
if(mysqli_query($conn, $create_db) )
else
mysqli_close($conn);
?>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<body>
Mehak(02016702018)<br><br><br>
</body>
</html>
<?php
// Create connection
// Check connection
if (!$conn) {
)";
if (mysqli_query($conn, $create_table))
else
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
mysqli_close($conn);
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<head>
<title>
</title>
</head>
<body>
Mehak(02016702018)<br><br>
<center>
</center>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
$name = $_POST['name'];
$dob = $_POST['dob'];
$salary = $_POST['sal'];
VALUES ('$name','$dob','$salary')";
if (mysqli_query($conn, $sql)) {
} else {
mysqli_close($conn); }
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .27-WAP to update any one record in the employee table, which
is in mydb database.
<html>
<head>
<title>
</title>
</head>
<body>
Mehak(02016702018)<br><br>
<center>
<hr>
</center>
</form>
</body>
</html>
<?php
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
if(isset($_POST['submit']))
$name = $_POST['name'];
$dob = $_POST['dob'];
$salary = $_POST['sal'];
$ID = $_POST['id'];
if (mysqli_query($conn, $update)) {
} else {
mysqli_close($conn);
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .28-WAP to design a format & display all records from the
employee table, which is in mydb database.
<?php
$row= mysqli_fetch_array($select_result);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Employees</title>
</head>
<body>
<center>Mehak(02016702018)<br><br></center>
<div class="container">
<div class="row">
<div class="col-lg-12"><h4>Employees</h4></div>
</div>
<div class="container">
<div class="row">
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
<div class="col-lg-2">ID</div>
</div>
<div class="row">
<div class="col-lg-2">Name</div>
</div>
<div class="row">
<div class="col-lg-2">DOB</div>
</div>
<div class="row">
<div class="col-lg-2">Salary</div>
</div>
<hr/>
<?php } ?>
</div>
</body>
</html>
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .29- WAP to delete a particular record form the employee table,
which is in mydb database.
<html>
<head>
<title>
</title>
</head>
<body><center>
Mehak(02016702018)<br><br>
<hr>
</center>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
$ID = $_POST['id'];
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
if (mysqli_query($conn, $delete)) {
} else {
mysqli_close($conn);
?>
OUTPUT :
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
QUE .30- WAP to design a format & display all records from the
employee table, which is in mydb database (Using select query with
order by clause).
<h4> <center>Mehak(02016702018)<BR><BR></center>
<h3 align='center'> Data of employee table arranged by ascending order of the salaries</h3>
<hr>
<?php
echo "<tr>";
echo "<th>id</th>";
echo "<th>name</th>";
echo "<th>dob</th>";
echo "<th>salary</th>";
echo "</tr>";
while($row = mysqli_fetch_array($res)){
echo "<tr>";
echo "</tr>";
MEHAK
(02016702018)
PHP Practical File BCA V Sem(morning)
echo "</table></centre>";
mysqli_free_result($res);
} else{
} else{
. mysqli_error($link); }
mysqli_close($link);
?>
OUTPUT :
MEHAK
(02016702018)