PHP Assignment
PHP Assignment
Topic – SQL
Task-1 :
Table Name :- Employee
1|Page
Table Name :- Incentives
B1. Get First_Name from employee table using alias name “Employee Name”.
B2. Get FIRST_NAME, Joining year, Joining Month and Joining Date from employee
table.
B3. Get all employee details from the employee table order by First_Name
Ascending and Salary descending.
B4. Get employee details from employee table whose first name contains ‘o’.
I1. Get employee details from employee table whose joining month is “January”.
I2. Get department, total salary with respect to a department from employee table order
by total salary descending.
I3. Get department wise maximum salary from employee table order by salary
ascending.
I4. Select first_name, incentive amount from employee and incentives table for those
employees who have incentives and incentive amount greater than 3000
A2. Select first_name, incentive amount from employee and incentives table for all
employees who got incentives using left join.
2|Page
A3. Create View OF Employee table in which store first name ,last name and salary
only.
A5. Create After Insert trigger on Employee table which insert records in view table.
Task-2 :
3|Page
B1. All orders for more than $1000.
B2. Names and cities of all salespeople in London with commission above 0.10.
B4. All salespeople with commission between 0.10 and 0.12. (Boundary values should
be excluded).
I1. All orders taken on Oct 3Rd and Oct 4th 1994.
I4. All customers excluding those with rating <= 100 unless they are located in Rome.
A1. All orders except those with 0 or NULL value in amt field.
A2. Count the number of salespeople currently listing orders in the order table.
4|Page
A3. Largest order taken by each salesperson, datewise.
A4. Largest order taken by each salesperson with order value more than
$3000. (ie same city).
Task-3 :
Create DataBase: Practice
Note: Use Create SQL statement for creating table.
CreateTable:
5|Page
6|Page
7|Page
B1. Return the FirstName, LastName, ProductName, and SalePrice for all
products sold in the month of October2005.
I1. Add the following Customer and Sale information to the database.
(using store procedure)
FirstName : Priyanka
LastName : Chopra
City:Mumbai
State:MH
Zip:400001
ProductID:3
SalePrice:205
SaleDate:12/31/2005
I2. Return the Product Category and the average Sale Price for those customers
who have purchased two or more products.
A1. Update the Sale Price to the Recommended Sale Price of those Sales
occurring between 6/10/2005and6/20/2005.
A3. Without using a declared iterative construct, return Sale Date and the
running total for all sales, ordered by the Sale Date in Ascending Order.
8|Page
Task-4 :
Note : Operatinal Statement with Employement.
tblemp(eno,ename,bdate,title,salary, dno),
tblproj(pno,pname,budget,dno),
tbldept(dno,dname,mgreno),
tblworkson(eno,pno,resp,hours).
B1. Write an SQL query that returns the project number and name for projects
with a budget greater than $100,000.
B2. Write an SQL query that returns all works on records where hours worked
is less than10and the responsibility is “Manager”.
B3. Write an SQL query that returns the employees (number and name only)
who have a title of “EEE‟ or “SA‟ and make more than $35,000.
B4. Write an SQL query that returns the employees (name only) in department
“D1‟ordered by decreasing salary.
I1. Write an SQL query that returns the departments (all fields) ordered by
ascending department name.
I2. Write an SQL query that returns the employee name, department name, and
employee title.
I3. Write SQL query that returns the project name, hours worked, and project
number for all works on records where hours > 10.
A1. Write an SQL query that returns the project name, department name, and
budget for all projects with a budget < $50,000.
A2. Write an SQL query that returns the employee numbers and salaries of all
employees in the “Consulting” department ordered by descending salary.
A3. Write an SQL query that returns the employee name, project name,
employee title and hours for all works on records.
9|Page
Module-2
Topic – HTML
B1.
I1.
10 | P a g e
A1.
11 | P a g e
Module-3
Topic – CSS
12 | P a g e
B2. Draw following table.
13 | P a g e
I2. Create following structure using div & span tag.
A1. Take any user-side templates and customize it and create any five pages like
(Home, About Us, Contact Us, Portfolio, Services).
A2. Take any admin template and customize it and create any five pages (Start
from login page).
14 | P a g e
Module-4
Topic – CORE PHP
B1 Write a PHP program to enter marks of five subjects Physics, Chemistry,
Biology, Mathematics and Computer, calculate percentage and grade by if
else Write a PHP program for find ‘Thursday’ in week using switch
function.
B2 Write a PHP program to check Leap years between 1901 to 2016 using
nested if.
B3 Write a PHP program to find the largest of three numbers using ternary
operator.
B8 Write a PHP program in which enter Amount, Year, Rate by form and find
the simple interest.
B10 Write a PHP program in which take three numbers by form and find the
minimum and maximum numbers from it.
B11 Write a PHP program in which enter basic salary, DA, HRA , PF by form
and find the Gross Salary.
15 | P a g e
B13 What is meant by variable variables in PHP?
I1
Write a program to print the below format :
159
2 6 10
3 7 11
4 8 12
*****
* *
* *
* *
*****
I3
$str1 = 'yabadabadoo';
$str2 = 'yaba';
if (strpos($str1,$str2)) {
echo "\"" . $str1 . "\" contains \"" . $str2 . "\"";
} else {
echo "\"" . $str1 . "\" does not contain \"" . $str2 . "\"";
}
Output:?
16 | P a g e
I4 What will be the output of the code below and why?
$x = 5;
echo $x;
echo "<br />";
echo $x+++$x++;
echo "<br />";
echo $x;
echo "<br />";
echo $x---$x--;
echo "<br />";
echo $x;
I5 What will be the values of $a and $b after the code below is executed?
Explain your answer.
$a = '1';
$b = &$a;
$b = "2$b";
I6 How can you tell if a number is even or odd without using any condition
or loop?
17 | P a g e
Module-5
Topic – Functions
B3 Which function is used in PHP to check the data type of any variable?
B4 How can you increase the maximum execution time of a script in PHP?
B6 Which function you can use in PHP to open a file for reading or writing or
for both?
B8 Which functions are used to count the total number of array elements in
PHP?
I1 Write a Program for finding the biggest number in an array without using
any array functions.
I2 How can you declare the array(all type) in PHP? Explain with example
I7 Use a for loop to total the contents of an integer array called numbers
which has five elements. Store the result in an integer called total.
Expected Output :
Title : The Cuckoos Calling
Author : Robert Galbraith
Publisher : Little Brown
A2 Write a PHP script that inserts a new item in an array in any position.
Expected Output :
Original array :
12345
19 | P a g e
A3 Write a PHP function to change the following array's all values to upper or
lower case.
Sample arrays :
$Color = array('A' => 'Blue', 'B' => 'Green', 'c' => 'Red');
Expected Output :
Values are in lower case.
Array ( [A] => blue [B] => green [c] => red )
Values are in upper case.
Array ( [A] => BLUE [B] => GREEN [c] => RED )
A4 Write a PHP script to get the shortest/longest string length from an array.
Expected Output :
1.15
100.2578
-2.964
A8 Write a PHP script to print "second" and Red from the following array.
Sample Data :
$color = array ( "color" => array ( "a" => "Red", "b" => "Green", "c" =>
"White"),
"numbers" => array ( 1, 2, 3, 4, 5, 6 ),
"holes" => array ( "First", 5 => "Second", "Third"));
A11 Write a PHP program using array function for above array type to find:
a)$a=array(“a”,”b”,”c”)
b) $b=array (“JAVA”,”PHP”,”ASP”)
c) Merge array $a & $b
d) Find “JAVA” in $b
e) Reveres array of $b
f) Merge two $a & $b array
A12 Write a PHP program using array function for above array type to find:
$a=array(“a”=>”rajesh”,”b”=>”nirav”,”c”=>”varun”)
$b=array(“c”=>”varun”,”d”=”kaushal”,”e”=>”mehul”)
a)Find Difference in two array $c & $d`
b)Compute Intersection in $c & $d
c)Remove last element of $c
d)check value “Nirav” exits or not from $c
e)Exchange all key with their value of $d
f)Split $c array in chunks
A14 Assign the character value 'Z' to the fourth element of the letters array
21 | P a g e
A16 Write a PHP script to calculate a number of days between two dates.
A17 Write a PHP script to get the first and last day of a month from a specified
date.
A19 Write a PHP script to check whether the given dates are valid or not?
A20 Write a PHP script to get time difference in days and years, months, days,
hours, minutes, seconds between two dates.
Note: Use DateTime class.
( $date1 = new DateTime('2012-06-01 02:12:51');
$date2 = $date1->diff(new DateTime('2014-05-12 11:10:00'));)
A23 Write a PHP script to add/subtract the number of days from a particular
date.
Sample Output : Original date : 2011-01-01
Before 40 days : 2010-11-22
After 40 days : 2011-02-10
A25 Write a PHP script to convert seconds into days, hours, minutes and
seconds.
Sample seconds : 200000
Expected output : 2 days, 7 hours, 33 minutes and 20 second
22 | P a g e
A26 Write a PHP script to : -
a) transform a string all uppercase letters.
b) transform a string all lowercase letters.
c) make a string's first character uppercase.
d) make a string's first character of all the words uppercase.
A29 Write a PHP script to extract the file name from the following string
Sample String : 'www.example.com/public_html/index.php'
Expected Output : 'index.php'.
A30 Write a PHP script to extract the user name from the following email ID.
Sample String : 'rayy@example.com'
Expected Output : 'rayy'
A31 Write a PHP script to find the first character that is different between two
strings.
String1 : 'football'
String2 : 'footboll'
Expected Result : First difference between two strings at position 5: "a" vs
"o"
A32 Write a PHP script to print the next character of a specific character.
Sample character : 'a'
Expected Output : 'b'
Sample character : 'z'
Expected Output : 'a'
A33 Write a PHP Program to create two form test1 & test2 and redirect test1 to
test2 in 5 second.
23 | P a g e
A34 Write a PHP Program to download & read file for PDF,
TEXT,JPF&WORD file.
A35 Write a PHP script to get the first and last day of a month from a specified
date.
A36 Write a PHP function to get start and end date of a week (by week
number) of a particular year.
A37 Write a PHP Program to using Date function to find default time zone with
date and time in 20 Nov, 2016, 10:30 am.
A38 Write a PHP Program to using Date function to finddate before 3 months
from current date.
Find Time of before two hours from current time.
A39 Write a PHP Program to create current date & time by usingmktime()
&strtotime().
24 | P a g e
Module-5
Topic – Super Global Variables
B1 What are uses of GET, POST and REQUEST?
B2 What is SESSION?
25 | P a g e
I6 How we can retrieve cookies.
I11 Write a PHP script, to check whether the page is called from 'https' or
'http'.
I13 Write a PHP script to get the time of the last modification of the current
page.
I15 Write a PHP Program to using Global Variable to find information about
header, path, script Location.
I16 Write a PHP Program to input value like id, name, pass in form test1 &
get(show) value in test2 form to using method get & post with $_GET,
$_POST and $_REQUEST function.
I18 Write a PHP script to get the PHP version and configuration information.
A1 Upload image with server side validation for image side should not be
greater than 1MB and allow JPG/JPEG/PNG (Image Format Only).
26 | P a g e
A3 Save username and password on browser and perform remember me
functionality.
27 | P a g e
Module-6
Topic – OOPS
B1 What Is Object Oriented Programming?
B4 What Is Overloading?
28 | P a g e
I10 What is the difference between Abstract class and Interface?
I11 Create parent class for car and child class for car_model and use car
functionality in car_model class.
I12 Override the parent’s properties and methods in the child class?
I13 Prevent the child class from overriding the parent’s methods?
I15 Can we have non abstract methods inside an abstract class? Explain With
Example
29 | P a g e
Module-7
Topic – MVC
B1 Create a registration(signup.php) page which will have following fields
(Start after complete Form get post method)
a. Username<textbox>
b. Password<password>
c. FirstName<textbox>
d. MiddleName<textbox>
e. LastName <textbox>
f. Email Address<textbox>
g. Phoneno.<textbox>
h. Address<textarea>
i. Country<dropdown>
j. State<dropdown>
k. city<dropdown>
l. Profile Picture
m. Gender<radiobutton>
n. Interest
n.i. News<checkbox>
n.ii. Health<checkbox>
n.iii. Automobiles<checkbox>
n.iv. Internet<checkbox>
o. Submit<submit> Cancel<reset>
B4 Apply CSS to all above pages. And make index page attractive like put
login area in the center with field set.
30 | P a g e
B5 Now create admin login table and insert manually admin username and
password.
B6 Then create an admin login page as you ‟We created for user. Now admin
enters wrong
username/password user should get message “invalid username/password”
else if
user enter username=<your username> and password=<your password>then
he/she should be
redirected to his homepage(adminhome.php). And admin home. Php admin
should get
message “Welcome,<adminname>” and a logout link clicking upon it user
should be
redirected to admin login.php.
(Hint: use Select Query)
B7 Consider the form from exercise1.Clicking upon submit button all fields
should be displayed on confirm. Php page and in confirm. Php page there
should be a link which takes user to the login page(index.php).
I1 Create one database. In that database create registration table. Now consider
exercise
I2 When user clicks on the submit button all data should be inserted into the
registration
table. Note:-User name must be unique.
31 | P a g e
I4 On admin homepage you have to create two link
1) Add user Detail
2) View user Detail.
Clicking on view user detail admin show all the user detail
I8 Consider the exercise11and add a edit link near delete link e.g.
32 | P a g e
I9 Create Hotel Room Booking System
1) Full day
2) Half day
3) Custom
If user select for the full day than user only have selection for the checking
checkout date
If user select Half day than user have option of date and slot option (like
user want to book
room for first half – Morning (8AM to 6PM) if user select for second half
it’s for evening (7PM to Morning 7AM)).
Do proper validation like if user can book only available slot. (have to use
jQuery -> Ajax, validation, Json passing).
33 | P a g e
Module-8
Topic – JAVASCRIPT/JQUERY
B1 What is jQuery?
B8 How To Show The Alert Message On Button Click In Jquery? And explain
multiple alert box
I6 Can You Give An Example For Chaining Along With Code Snippet?
34 | P a g e
I8 How We Can Select The Specified <li> Element From The List Of <li>
Elements In <ul>?
35 | P a g e
Module-9
Topic – Web Services
1. Create web-services which fetch the data from server by json_encode and
also decode it.
36 | P a g e
Module-10
Topic – CodeIgniter
Admin Side
User Side
37 | P a g e