11. Build a web application to accept book information viz.
Accession number, title, authors,
edition and publisher from a web page and store the information in a database and to search
for a book with the title specified by the user and to display the search results with proper
headings. Also perform insert, delete and edit operation. [Hint: use PHP, CSS, and MySQL.
Check all validations and add proper constraints for tables]
Answer
create table book(an numeric primary key,title varchar(20), author varchar(20),edition
varchar(20),publisher varchar(20));
Book Registration form
<html>
<head>
</head>
<body>
<h2>Book information system</h2>
<form action="bookcode.php">
Accession number<input type=text name="an"><br>
title<input type="text" name=title ><br>
authors<input type=text name=author><br>
edition <input type=text name=ed><br>
publisher <input type=text name=pb><br>
<input type="submit" name="s">
</form>
</body>
</html>
Book Registartion code
<?php
$an=$_REQUEST['an'];
$title=$_REQUEST['title'];
$author=$_REQUEST['author'];
$edi=$_REQUEST['ed'];
$pb=$_REQUEST['pb'];
$con=mysql_connect("localhost","root","");
mysql_select_db("myphplab",$con);
$qry="insert into book values($an,'$title','$author','$edi','$pb')";
$cnt=mysql_query($qry,$con);
if($cnt>0)
echo "saved";
?>
Search for a book
<html>
<head></head>
<body>
<h2>Search a Book </h2>
<form action="searchbook.php">
title<input type="text" name=title ><br><br>
<input type="submit" name="s">
</form>
<?php
if(isset($_REQUEST['title']))
{
$t=$_REQUEST['title'];
$con=mysql_connect("localhost","root","");
mysql_select_db("myphplab",$con);
$qry="select * from book where title='$t' ";
$result=mysql_query($qry,$con);
?>
<h2>Number Title Author <h2>
<h2>
<?php
while($row=mysql_fetch_array($result))
{
echo $row['an']."
".$row['title']."
".$row['author'];
}
}
?>
</h2>
</body>
</html>
12. Employee Details, to perform display, insert, update & delete
operations on employee details using php, CSS,HTML and
MySQL database.[Hint: create tables add proper constraints,
check all validations]
Answer
create table employee(empid numeric primary key,empname varchar(20), age
numeric,desg varchar(20));
Employee Registration
<html>
<head></head>
<body>
<h2>Employee Registration form</h2>
<form action="empcode.php">
Employee number<input type=text name="en"><br>
Name<input type="text" name=nm ><br>
Age<input type=text name=age><br>
Designation<input type=text name=dg><br>
<input type="submit" name="s">
</form>
</body>
</html>
Employee registration code
<?php
$empno=$_REQUEST['en'];
$name=$_REQUEST['nm'];
$age=$_REQUEST['age'];
$dg=$_REQUEST['dg'];
$con=mysql_connect("localhost","root","");
mysql_select_db("myphplab",$con);
$qry="insert into employee values($empno,'$name',$age,'$dg')";
$cnt=mysql_query($qry,$con);
if($cnt>0)
echo "saved";
?>
Employee updation page
<html>
<head></head>
<body>
<h2>Employee Registration form</h2>
<form action="empup.php">
Employee number<input type=text name="en"><br>
Name<input type="text" name=nm ><br>
Age<input type=text name=age><br>
Designation<input type=text name=dg><br>
<input type="submit" name="s" value="update">
</form>
</body>
</html>
Employee updation code
<?php
$empno=$_REQUEST['en'];
$name=$_REQUEST['nm'];
$age=$_REQUEST['age'];
$dg=$_REQUEST['dg'];
$con=mysql_connect("localhost","root","");
mysql_select_db("myphplab",$con);
$qry="update employee set empname='$name',age=$age,desg='$dg' where
empid=$empno";
$cnt=mysql_query($qry,$con);
if($cnt>0)
echo "updated";
?>
Employee deletion page
<html>
<head></head>
<body>
<h2>Employee Registration form</h2>
<form action="empd.php">
Employee number<input type=text name="en"><br>
<input type="submit" name="s" value="delete">
</form>
</body>
</html>
Deletion code
<?php
$empno=$_REQUEST['en'];
$con=mysql_connect("localhost","root","");
mysql_select_db("myphplab",$con);
$qry="delete from employee where empid=$empno";
$cnt=mysql_query($qry,$con);
if($cnt>0)
echo "deleted";
?>
13. Create a web application using PHP, CSS & MYSQL program to
prepare a Bill for a super market. Perform insert, delete, edit and search
operations.[Hint: Create minimum two tables, check all validations and
add proper constraints for tables]
14. Write a web program to calculate electricity bill. Perform insert, delete,
edit and search operations.[Hint: use PHP, MySQL, CSS, html create
tables add proper constraints, check all validations, Conditions: For first
50 units – Rs. 3.50/unit. For next 100 units – Rs. 4.00/unit, For next 100
units – Rs. 5.20/unit For units above 250 – Rs. 6.50/unit]
15. Design a web application for Student Information system. create tables
and add proper constrains. Perform insert, delete and search operation.