PHP Workbook-SEM-II
Assignment 1
PHP-MySQL
1. Consider the following entities and their relationships
Emp (emp_no,emp_name,address,phone,salary)
Dept (dept_no,dept_name,location)
Emp-Dept are related with one-many relationship
Create a RDB in 3NF for the above and solve following
Using above database write a PHP script which will
a) Insert employee records & department records into the respective
tables.
b) Print a salary statement in the format given below, for a given
department. (Accept department name from the user).
Maximum Salary Minimum Salary Sum Salary
2. Consider the following entities and their relationships
Doctor (doc_no, doc_name, address, city, area)
Hospital (hosp_no, hosp_name, hosp_city)
Doctor and Hospital are related with many-many relationship
Create a RDB in 3 NF for the above and solve following
Using above database, write a PHP script which accepts hospital name
and print information about doctors visiting / working in that hospital in
tabular format.
3. Consider the following entities and their relationships
Movie (movie_no, movie_name, release_year)
Actor (actor_no, name)
Relationship between movie and actor is many – many with attribute rate
in Rs. Create a RDB in 3 NF for the above and solve following
Using above database, write PHP scripts for the following:
(Hint: Create HTML form having three radio buttons)
a) Accept actor name and display the names of the movies in which he has
acted.
b) Insert new movie information.
Page 1
c) Update the release year of a movie. (Accept the movie name from user)
4. Consider the following entities and their relationships
Student (Stud_id,name,class)
Competition (c_no,c_name,type)
Relationship between student and competition is many-many with attribute rank
and year. Create a RDB in 3NF for the above and solve the following.
Using above database write a script in PHP to accept a competition name from
user and display information of student who has secured 1st rank in that
competition.
Page 2
Assignment 2
Graphics
1. Write a script in PHP to divide the output screen into four quadrants and draw
the following graphical shapes ,in each of them and save the file as “shapes.php”
a) Ist quadrant – Triangle
b) IInd quadrant- Square
c) IIIrd quadrant-Pentagon
d) IVth quadrant- Polygon (having six sides)
(Note: all above mentioned shapes should be filled with different colors.)
2. Write a PHP script
a) To draw an image of several concentric circles with randomly generated colors.
Save this file as “circle.php”
b) Add the following text,” Welcome to mind game” to the above file.
3. Create a form to accept the following information
Create image
Width: Height:
Text Color Red: Green: Blue:
Text String:
X Co-ordinate: Y Co-ordinate:
Shape:
Draw Image
Page 3
4) Write a script to
a. create a image file php.jpeg as shown in figure1 below and smoothly scale it down to
one-quarter of its size, yielding the image in figure2.
Figure1
Figure2
b. Divide the height and the width by 4 instead of 2 and produce the output, as shown
below in figure3.
Figure3
5. Write a PHP script to
a) Draw a picture of a Desk top computer and save this picture as “comp.jpeg”.
b) Open the above picture, as a watermark, and resave it with the same filename.
6. Write a PHP script to draw image, without using multiple draw rectangle image.
Page 4
7. Write a PHP script to draw following image.
Page 5
Assignment3
XML
1. Write a script to create XML file named “Rajashree.xml”
The element details of “Rajashree .xml” are:
<Rajashree Productions>
<Movie>
<MovieName>……….</MovieName>
<Actor Name>…………</ActorName>
<ReleaseYear>…………</ReleaseYear>
</Movie>
</RajashreeProductions>
Store details of at least 5 movies which got released during 1990-2010.
2. Link “Rajashree.xml” file to the CSS style sheet and get well formatted output as given
below.
a)MovieName :
Color: black,
Font-family: Copperplate Gothic Light;
Font Size: 16 pts;
Font:Bold;
b)ActorName and ReleaseYear:
Color: Red;
Font-family: Bodoni MT;
Font Size: 12 pts;
Font:Bold
3. Write a PHP script to generate an XML in the following format
<?xml version = “1.0” encoding = “ISO-8859-1” ?>
<BookStore>
<Books>
<PHP>
<title>Programming PHP</title>
<publication>O’RELLY</publication>
</PHP>
<PHP>
<title>Beginners PHP</title>
<publication>WROX</publication>
</PHP>
</Books>
Page 6
</BookStore>
4. Create a XML file which gives details of books available in “ ABC Bookstore” from
following categories.
1) Technical
2) Cooking
3) Yoga
and elements in each category are in the following format
<Book>
<Book_PubYear> --------------</Book_PubYear>
<Book_Title> --------------</Book_Title>
<Book_Author> ---------------</Book_Author>
</Book>
Save the file as “Book.xml”
5. Write a script to solve following questions (Use “Book.xml” file)
a) Create a DomDocument object and load this XML file.
b) Get the output of this Document to the browser
c) Save this [. XML] document in another format i.e. in [.doc]
d) Write a XML program to print the names of the books available in”Book.xml”
file.
6. Create an application that reads “Book.xml” file into simple XML object. Display
attributes and elements.(Hint: Use simple_xml_load_file() function)
7. Write a script to create “cricket.xml” file with multiple elements as shown below:
<CricketTeam>
<Team country=”India”>
<player>____</player>
<runs>______</runs>
<wicket>____</wicket>
</CricketTeam>
a) Write a script to add multiple elements in “cricket.xml” file of category,
country=”Australia”.
Page 7
Assignment4
E-mail
1. Write a PHP script to design a form to compose/write an email with the following
details:
To:
From:
Subject:
Text:
Date/Time:
a) Accept Date/Time from the system.
b) Validate the e-mail addresses for TO and From using regular expressions.
c) Send the email.
d) Design necessary screen layouts for the same.
Page 8