Question 1
a) Write a simple PHP program that dynamically populates a dropdown list on page load with values retrieved from Database db_restaurant from table tbl_dish containing two fields namely dish_ID and dish_Name. Clearly state any assumptions you make.
b) Using table Student above, write an SQL query to retrieve the student record with the lowest marks.
student_ID
|
first name |
last name |
marks
|
001
|
Steve
|
Highway
|
40
|
002
|
Bill
|
Johnson
|
80
|
003
|
Denis
|
Neeson
|
90
|
004
|
Sam
|
Button
|
70
|
Question 2
a. The form below contains an input text box for a user to enter his name and a group of radio buttons to select his gender. Write the PHP script to print the user's name and a welcome message depending on his gender:
• For males - "Sports items on special offer"
• For females - "50% discount on handbags"
b. Consider a server with the following settings:
servername: localhost database name: monthsDB username: donald password: jerry
Create a connection string to connect to this database and explain each line of code.
C . What will be the output of the following extract codes? Describe fully how the program operates.
$states_of_the_USA = array (1 => "Alabama", "Alaska", "Arizona");
$x = array_count_values($states_of_the_USA); for ($counter=1; $counter<$x; $counter++) { echo"
$states_of_the_USA[$counter]";
}
?>
D) Write a PHP program to calculate and display the factorial of any number entered into a Text Box field.
Note: You will have to use a recursive function.
E) Distinguish between the include() statement and the require() statement.