PHP Assignments
PHP Assignments
SET A:
Q1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=>, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<p>List Of indian states with their capital</p>
<ol>
<li>Delhi</li>
<ul>
<li>New Delhi</li>
</ul>
<li>Haryana</li>
<ul>
<li>Chandigarh</li>
</ul>
<li>Gujarat</li>
<ul>
<li>Gandhinagar</li>
</ul>
<li>Rajasthan</li>
<ul>
<li>Jaipur</li>
</ul>
<li>Maharahtra</li>
<ul>
<li>Mumbai</li>
</ul>
<li>Uttarpradesh</li>
<ul>
<li>Lucknow</li>
</ul>
</ol>
</body>
</html>
Q2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=>, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<p>List of books</p>
<table border="1px">
<tr>
<td rowspan="2">Item No</td>
<td rowspan="2">Item Name</td>
<td colspan="2">Price</td>
</tr>
<tr>
<th>Rs</th>
<th>Paise</th>
</tr>
<tr>
<th>1</th>
<td>Programming in python</td>
<td>500</td>
<td>50</td>
</tr>
<tr>
<th>2</th>
<td>Programming in java</td>
<td>345</td>
<td>00</td>
</tr>
</table>
</body>
</html>
Q3.
<!DOCTYPE html>
<html>
<head>
<title>Assignment</title>
</head>
<frameset rows="20%,60%,20%">
<frame src="header.html" />
<frame src="middle.html" />
<frame src="footer.html" />
</frameset>
</html>
<!DOCTYPE html>
<html>
<head>
<title>header</title>
</head>
<body>
<p><b>This is a header.</b></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>footer</title>
</head>
<body>
<p><b>This is a footer.</b></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>middle</title>
</head>
<frameset cols="30%,70%">
<frame src="left.html" />
<frame src="right.html" />
</frameset>
</html>
<!DOCTYPE html>
<html>
<head>
<title>left</title>
</head>
<body>
<p>Look in the box at the right for some information.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Right</title>
</head>
<body>
<p>Here is some information.</p>
</body>
</html>
SET B:
1)
<!DOCTYPE html>
<html>
<head>
<style>
.design {
font-size: 6pt;
color: red;
background-color: yellow;
line-height: 2;
}
</style>
<title>Assignment</title>
</head>
<body>
<div class="design">
<p>Operating System Information</p>
</div>
<form>
Enter Your Name:<input type="text" name="name" /><br />
/* basic css */
width: 140px;
height: 40px;
background: white;
outline: 3px solid black;
}
.row2 {
/* text allign */
text-align: center;
vertical-align: middle;
line-height: 40px;
/* basic css */
width: 180px;
height: 40px;
background: white;
outline: 3px solid black;
}
</style>
<title>Assignment</title>
</head>
<body>
<div class="yellow">
<div class="red">
<div class="row1">T.Y.Bsc(Comp Sci)</div>
<div class="row2">Academic Year 2021-2022</div>
</div>
</div>
</body>
</html>
2)
<!DOCTYPE html>
<html>
<head>
<title>Assignment</title>
<style>
ul {
list-style-type: none;
text-align: center;
margin: 0;
padding: 0;
overflow: hidden;
background-color: lightgray;
}
li {
float: left;
}
li a {
display: block;
color: blue;
text-align: center;
padding: 16px;
text-decoration: none;
}
li a:hover {
background-color: gray;
color: white;
}
</style>
</head>
<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#java">JAVA</a></li>
<li><a href="#html">HTML</a></li>
<li><a href="#css">CSS</a></li>
</ul>
</body>
</html>
Assignment 2:
SET A:
Html code:
<div class="container">
<div class="row margin-top">
<div class="col-sm-4 block1">
<h1>block 1</h1>
</div>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 hidden-xs empty-block">
</div>
</div>
<div class="row">
<div class="col-sm-12 block2">
<h1>block 2</h1>
</div>
</div>
</div>
</div>
<div class="row margin-top">
<div class="col-sm-12 block-contain">
<div class="row">
<div class="col-sm-12 col-md-6">
<div class="row">
<div class="col-sm-12 block3">
<h1>block 3</h1>
</div>
</div>
<div class="row">
<div class="col-sm-6 block4">
<h1>block 4</h1>
</div>
<div class="col-sm-6 block5">
<h1>block 5</h1>
</div>
</div>
</div>
<div class="col-sm-12 col-md-3 block6">
<h1>block 6</h1>
</div>
<div class="col-sm-12 col-md-3">
<div class="row">
<div class="col-sm-12 block7">
<h1>block 7</h1>
</div>
</div>
<div class="row">
<div class="col-sm-12 block8">
<h1>block 8</h1>
</div>
</div>
<div class="row">
<div class="col-sm-12 block9">
<h1>block 9</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Css code:
body {
text-align: center;
color: white;
background-color: #f0f0f0;
}
h1 {
margin-top: 40px;
}
.margin-top {
margin-top: 10px;
}
.block1 {
height: 300px;
background-color: #42a8c8;
border: 5px solid #f0f0f0;
}
.empty-block {
height: 150px;
}
.block2 {
height: 150px;
background-color: #5bbfb4;
border: 5px solid #f0f0f0;
}
.block-contain {
height: 620px;
}
.block3 {
height: 310px;
background-color: #5bbfb4;
border: 5px solid #f0f0f0;
}
.block4 {
height: 300px;
background-color: #42a8c8;
margin-top: 10px;
border: 5px solid #f0f0f0;
}
.block5 {
height: 300px;
background-color: #5bbfb4;
margin-top: 10px;
border: 5px solid #f0f0f0;
}
.block6 {
height: 620px;
background-color: #42a8c8;
border: 5px solid #f0f0f0;
}
.block7 {
height: 150px;
background-color: #5bbfb4;
border: 5px solid #f0f0f0;
}
.block8 {
height: 150px;
background-color: #42a8c8;
margin-top: 10px;
border: 5px solid #f0f0f0;
}
.block9 {
height: 300px;
background-color: #5bbfb4;
margin-top: 10px;
border: 5px solid #f0f0f0;
}
SET B:
Q1:
Html code:
<div id="viewport">
<!-- Sidebar -->
<div id="sidebar">
<header>
<a href="#">My App</a>
</header>
<ul class="nav">
<li>
<a href="#">
<i class="zmdi zmdi-view-dashboard"></i> Dashboard
</a>
</li>
<li>
<a href="#">
<i class="zmdi zmdi-link"></i> Shortcuts
</a>
</li>
<li>
<a href="#">
<i class="zmdi zmdi-widgets"></i> Overview
</a>
</li>
<li>
<a href="#">
<i class="zmdi zmdi-calendar"></i> Events
</a>
</li>
<li>
<a href="#">
<i class="zmdi zmdi-info-outline"></i> About
</a>
</li>
<li>
<a href="#">
<i class="zmdi zmdi-settings"></i> Services
</a>
</li>
<li>
<a href="#">
<i class="zmdi zmdi-comment-more"></i> Contact
</a>
</li>
</ul>
</div>
<!-- Content -->
<div id="content">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#"><i class="zmdi zmdi-notifications text-danger"></i>
</a>
</li>
<li><a href="#">Test User</a></li>
</ul>
</div>
</nav>
<div class="container-fluid">
<h1>Simple Sidebar</h1>
<p>
Make sure to keep all page content within the
<code>#content</code>.
</p>
</div>
</div>
</div>
Css code:
@import url('https://fonts.googleapis.com/css?
family=Roboto:300,400,400i,500');
body {
overflow-x: hidden;
font-family: 'Roboto', sans-serif;
font-size: 16px;
}
/* Toggle Styles */
#viewport {
padding-left: 250px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#content {
width: 100%;
position: relative;
margin-right: 0;
}
/* Sidebar Styles */
#sidebar {
z-index: 1000;
position: fixed;
left: 250px;
width: 250px;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #37474F;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#sidebar header {
background-color: #263238;
font-size: 20px;
line-height: 52px;
text-align: center;
}
#sidebar header a {
color: #fff;
display: block;
text-decoration: none;
}
#sidebar .nav{
#sidebar .nav a{
background: none;
border-bottom: 1px solid #455A64;
color: #CFD8DC;
font-size: 14px;
padding: 16px 24px;
}
#sidebar .nav a i{
margin-right: 16px;
}
Q2.
Html code:
<link
href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
rel="stylesheet" id="bootstrap-css">
<script
src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></
script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="small-top">
<div class="container">
<div class="row">
<div class="col-lg-4 date-sec">
<div id="Date"></div>
</div>
<div class="col-lg-3 offset-lg-5">
<div class="social-icon"> <a target="_blank" href="#" class=" fa fa-
facebook"></a> <a target="_blank" href="#" class=" fa fa-twitter"></a> <a
target="_blank" href="#" class=" fa fa-google-plus"></a> <a target="_blank"
href="#" class=" fa fa-linkedin"></a> <a target="_blank" href="#" class=" fa fa-
youtube"></a> <a target="_blank" href="#" class=" fa fa-vimeo-square"></a>
</div>
</div>
</div>
</div>
</div>
<div class="top-head left">
<div class="container">
<div class="row">
<div class="col-md-6 col-lg-4">
<h1>Grafreez News<small>Get the latest News</small></h1>
</div>
<div class="col-md-6 col-lg-3 ml-auto admin-bar hidden-sm-down">
<nav class="nav nav-inline"> <a href="#" class="nav-link"><span
class="ping"></span><i class="fa fa-envelope-o"></i></a> <a href="#"
class="nav-link"><i class="fa fa-bell-o"></i></a> <a href="#" class="nav-
link">Bruce Wayne <img class="img-fluid rounded-circle"
src="http://grafreez.com/wp-content/temp_demos/river/img/admin-
bg.jpg"></a> </nav>
</div>
</div>
</div>
</div>
</header>
<section class="top-nav">
<nav class="navbar navbar-expand-lg py-0">
<div class="container">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="exCollapsingNavbar2">
<ul class="nav navbar-nav ">
<li class="nav-item active"> <a class="nav-link" href="#">Home <span
class="sr-only">(current)</span></a> </li>
<li class="nav-item"> <a class="nav-link" href="#">World</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Politics</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Business</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Science</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Sports</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Tech</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Travel</a> </li>
<li class="nav-item"> <a class="nav-link" href="#">Health</a> </li>
</ul>
<form class="ml-auto">
<div class="search">
<input type="text" class="form-control" maxlength="64"
placeholder="Search" />
<button type="submit" class="btn btn-search"><i class="fa fa-
search"></i></button>
</div>
</form>
</div>
</div>
</nav>
</section>
<section class="banner-sec">
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="card"> <img class="img-fluid" src="http://grafreez.com/wp-
content/temp_demos/river/img/politics.jpg" alt="">
<div class="card-img-overlay"> <span class="badge badge-pill badge-
danger">News</span> </div>
<div class="card-body">
<div class="news-title">
<h2 class=" title-small"><a href="#">Syria war: Why the battle for
Aleppo matters</a></h2>
</div>
<p class="card-text"><small class="text-time"><em>3 mins
ago</em></small></p>
</div>
</div>
<div class="card"> <img class="img-fluid" src="http://grafreez.com/wp-
content/temp_demos/river/img/travel.jpg" alt="">
<div class="card-img-overlay"> <span class="badge badge-pill badge-
danger">Politics</span> </div>
<div class="card-body">
<div class="news-title">
<h2 class=" title-small"><a href="#">Key Republicans sign letter
warning against</a></h2>
</div>
<p class="card-text"><small class="text-time"><em>3 mins
ago</em></small></p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card"> <img class="img-fluid" src="http://grafreez.com/wp-
content/temp_demos/river/img/business1.jpg" alt="">
<div class="card-img-overlay"> <span class="badge badge-pill badge-
danger">Travel</span> </div>
<div class="card-body">
<div class="news-title">
<h2 class=" title-small"><a href="#">Obamacare Appears to Be
Making People Healthier</a></h2>
</div>
<p class="card-text"><small class="text-time"><em>3 mins
ago</em></small></p>
</div>
</div>
<div class="card"> <img class="img-fluid" src="http://grafreez.com/wp-
content/temp_demos/river/img/food.jpg" alt="">
<div class="card-img-overlay"> <span class="badge badge-pill badge-
danger">News</span> </div>
<div class="card-body">
<div class="news-title">
<h2 class=" title-small"><a href="#">‘S.N.L.’ to Lose Two Longtime
Cast Members</a></h2>
</div>
<p class="card-text"><small class="text-time"><em>3 mins
ago</em></small></p>
</div>
</div>
</div>
<div class="col-md-6 top-slider">
<div id="carousel-example-generic" class="carousel slide" data-
ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0"
class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
body {
color: #5a5a5a;
font-family: 'Open Sans',Arial,sans-serif;
font-size: 15px;
}
h1,h2,h3,h4,h5{
font-family: 'Montserrat', sans-serif;
}
a, a:hover, .btn{outline:none!important;}
.btn-search{background: #FD3A13; border-color: #FD3A13; color: #fff; padding:
7px 10px}
.btn-search:hover{background: #ca1b1b; border-color: #ca1b1b}
section{padding: 30px 0; float: left; width: 100%}
.card{float: left; width:100%}
.navbar {border: medium none; float: left; margin-bottom: 0px; width: 100%;
border-radius: 0}
.title-large {font-size: 20px; margin: 10px 0 5px; line-height: 27px; color:
#141517;}
.title-small { color: #141517; font-size: 16px; font-weight: 400; line-height:
23px; margin: 6px 0 0;}
.title-x-small {font-size: 18px; margin: 0px;}
.title-large a, .title-small a, .title-x-small a{color: inherit}
.banner-sec{float: left; width: 100%; background: #EBEBEB}
.card-block{padding:0 10px 10px;}
.card-text{margin: 0}
.text-time{color: #ff0000; font-weight: 600;}
.banner-sec .card-img-overlay{padding: 0; top: 3px; left: 7px; height: 20%}
.top-slider .carousel-indicators{bottom: 0}
.top-slider .carousel-indicators li{border:1px solid #000;}
.top-slider .carousel-indicators .active{background:#000;}
.side-bar .nav-tabs{border-bottom:none;}
.side-bar .nav-tabs .nav-link {color: #aeaeae; text-transform: uppercase;
border: none;}
.side-bar .nav-tabs .nav-link.active, .side-bar .nav-tabs .nav-link:hover{border-
bottom:2px solid #ff0000; text-transform: uppercase; color: #222}
.sidebar-tabing .media{margin-top: 20px}
.sidebar-tabing img{width: 120px;height: 100px;}
.sidebar-tabing .title-small {line-height: 23px; margin-top: 5px; font-size: 18px}
Assignment 4:
SET A:
1)
<?php
$temp = array(1,2,3,4,5,6,4,5,2,2,22,1,2,12,32,12,32,54,2,3,12,2);
sort($temp);
$cold = array_slice($temp,0,5);
$hot = array_slice($temp,-6,-1);
echo "Top 5 cold temperatures = ";
foreach($cold as $c)
{
echo $c.",";
}
echo "<br>Top 5 hot temperatures = ";
// print_r(explode(",",$hot));
foreach($hot as $h)
{
echo $h.",";
}
echo "<br>";
$sum = 0;
foreach ($temp as $t)
{
$sum = $sum+$t;
}
$avg = $sum/count($temp);
echo "Avegare temperature = ".$avg;
?>
2)
<form method="POST">
<input type="radio" id="insert_s" name="choice" value="1">
<label for="insert_s">Insert an element in stack</label><br>
<input type="radio" id="delete_s" name="choice" value="2">
<label for="delete_s">Delete an element from stack</label><br>
<input type="radio" id="display_s" name="choice" value="3">
<label for="display_s">Display the contents of stack</label><br><br>
Value: <input type="text" name="value"><br><br>
<input type="submit" name="submit" value="submit">
</form>
<?php
if(isset($_POST['submit']))
{
$arr = array();
$choice = $_POST['choice'];
$val = $_POST['value'];
switch($choice)
{
case 1:
array_push($arr,$val);
break;
case 2:
array_pop($arr);
break;
case 3:
print_r($arr);
}
}
?>
SET B:
1)
<form method="POST">
Enter the position: <input type="text" name="pos"><br><br>
Enter the value: <input type="text" name="val"><br><br>
<input type="submit" name="submit">
</form>
<?php
if(isset($_POST['submit']))
{
$val = $_POST['val'];
$pos = $_POST['pos'];
$arr = array(1,2,3,4,5);
$arr1 = array_slice($arr,0,$pos-1);
$arr2 = array_slice($arr,$pos-1);
array_push($arr1,$val);
$arr3 = array_merge($arr1,$arr2);
foreach($arr3 as $a)
{
echo $a."<br>";
}
}
?>
2)
<form method="POST">
Enter the element to be searched: <input type="text"
name="value"><br><br>
<input type="submit" name="submit">
</form>
<?php
if(isset($_POST['submit']))
{
$val = $_POST['value'];
$arr = array(1,2,3,4,5,2,3,5,6,3);
$pos = array_search($val, $arr);
if(!empty($pos))
{
echo "Element found at position: ".$pos+1;
}
else
{
echo "Element not found in the array";
}
}
?>
Assignment 5:
SET A:
1)
<?php
?>
2)
<form method="POST">
<input type="text" name="title" style="font-size: 18px;"><br><br>
<input type="submit" name="sub" style="font-size: 18px;">
</form>
<?php
if(isset($_POST['sub']))
{
$t = $_POST['title'];
//echo "title = $t<br>";
$db = pg_connect("host=localhost dbname=ty user=postgres ");
//echo "xyz";
if($db)
{
//echo "connected";
$qry = "SELECT ec.cno from committee as c, ev_co as ec,
event as e where c.cno=ec.cno and e.eno=ec.eno and e.title='$t'";
$ret = pg_query($db,$qry);
$row = pg_fetch_row($ret);
$r = $row[0];
//echo "row = $r";
echo "<br>";
echo "<tr>";
echo "<td>".$data[0]."</td>";
echo "<td>".$data[1]."</td>";
echo "<td>".$data[2]."</td>";
echo "<td>".$data[3]."</td>";
echo "</tr>";
}
echo "</table>";
}
?>
2)
<form method="POST">
<input type="text" name="c_name"><br><br>
<input type="submit" name="sub">
</form>
<?php
if(isset($_POST['sub']))
{
$c = $_POST['c_name'];
$db = pg_connect("host=localhost dbname=ty user=postgres ");
if($db)
{
$qry = "SELECT sc.rank,s.name,s.calss,sc.year FROM student
as s, competition as c, stud_comp as sc where s.sid=sc.sid and c.cno=sc.cno
and sc.rank=1 and c.cname='$c'";
$ret = pg_query($db,$qry);
while($row = pg_fetch_row($ret))
{
echo "rank = $row[0]<br>";
echo "name = $row[1]<br>";
echo "class = $row[2]<br>";
echo "year = $row[3]<br>";
echo "<br>";
}
}
}
?>