PHP & MySQL assignment
PHP & MySQL assignment
1. Create a page evenodd.php into root directory of your local web server. Here, write a script for
finding out whether it is an odd number or even number and echo on the screen. The following
numbers set can be taken as input: 11, 23, 72 and 44.
2. Create a page vowel.php into root directory of your local web server. Write in the script for
determining whether or not the character associated with a variable is Vowel or a Consonant. If its
a Vowel echo out the name of the vowel otherwise echo out its a Consonant. Use Switch for this
script.
1. Write a PHP Script to declare 2 variables with specific numeric value of your choice and Perform
the following operations: Addition, Subtraction, Multiplication and Division. Also echo out the
Result on the screen.
2. Write a PHP Script to declare 2 variables with specific numeric value of your choice and find out
the greater number between the two. If the numbers are equal, the respective message must
appear on the screen.
III) Arrays
1. Declare an array week and assign the value of the days to each index number in the order of
occurrence and echo the result on the screen.
2. Write a PHP script to add the two 2x2 Matrices and output the result.
IV) Loops
*****
****
***
**
2. Declare an array variable "x" assigning it with three elements "one, two and three" and Use for
each loop to print the values of the given array.
V) Functions
1. Declare and define a function named writeName and within it echo out: Ramachandra. Now call
the function to retrieve the following output: My name is Ramachandra
2. Declare a function named writeName2 with a parameter $firstname and define it by echoing out:
$firstname." Sharma". Now call the function to retrieve the following output:
1. If the three sides of a triangle are entered by the user, write a program to check whether the
triangle is isosceles, equilateral, scalene or right angled triangle. Use the 'Get' method to post the
form.
2. Create a php page and create a user form which asks for marks in five subjects out of 100 and
then displays the marksheet of the student. The format is as follows:
Name of Student*:
Subject 1* :
Subject 2* :
Subject 3* :
Subject 4* :
Subject 5* :
Total Marks:
Percentage:
Note: All the entries marked (*) are to be input by the user. And use a submit button to post the
entries in the form using the POST method.