Hello. I am a grad student and I am a week behind in an html/php/mysql class. I have completed the code for each of the following assignments but they do not seem to work no matter how much I tweak them. My programming partner has been helpful, but he cannot tell me what I have missed and my professor isn’t geting back to me very quickly. I need to turn these in tomorrow. Can someone please look these over and make suggestions? The book we are using is Larry Ullman’s PHP. I am pasting the assignments and the code here:
ASSMT ONE:
Write an HTML form that will ask the user their name and favorite color (presented in a drop-down box) and then a corresponding PHP script that will greet them by name and set the background to the color they selected. Comment your code to describe its function. Assign meaningful names to your variables. Hint: Your PHP script can appear anywhere in the .php file, not just in the body section. Here is a sample CSS definition:
body {background-color: white; font-family: Geneva, Arial, Helvetica, sans-serif;}MY HTML FOR ASSMT ONE WORKS JUST FINE:
Welcome!Please enter your name and favorite color:
<p>First Name: <input type="text"
name="first_name" size="20" /></p>
<p>Last Name: <input type="text"
name="last_name" size="20" /></p>
<p>Favorite Color:
<select name="color">
<option value="">Pick One</option>
<option value="Red">Red</option>
<option value="Yellow">Yellow</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
</select></p>
<input type="submit" name="submit"
value="Submit" />
HOWEVER THERE IS SOMETHING WRONG WITH MY PHP CODE (eems to be a problem with my GET statement pertaining to the background color):
body {background-color: white; font-family: Geneva, Arial, Helvetica, sans-serif;} Welcome Page <?php // This is the php script entitled phpassignment1.php.ini_set (“display_errors”, 1); // Let me learn from my mistakes!
error_reporting (E-ALL | E_STRICT); // Show all possible problems!
// This page receives the data from phpassignment1.html.
// It will receive the first and last name and print them using $_GET.
$first_name = $_GET[‘first_name’];
$last_name = $_GET[‘last_name’];
// Print the received data:
print "
Thank you, $firstname $lastname!
;// Change the background color to reflect the user’s choice using $_GET:
$favorite_color = $_GET[‘favorite_color’];
body {favorite_color: $favorite_color;}?>
ASSMT TWO:
Generate a web page that displays multiplication tables for the numbers one through ten for students in grade school. Of course, you could write the whole thing by hand, but you wonder if it wouldn’t be easier to produce the page using php.
In order to complete the assignment, please fulfill the following requirements:
Using both for and while loops, create a php script that generates multiplication tables formatted in HTML tables.
Comment your code to describe the function of each section.
Assign meaningful names to your variables.
HINT: You can “nest” loops inside each other to reduce the work you have to do.
MY CODE THAT IS NOT WORKING (appears to be a syntax error in the while loop, probably in the print line):
Multiplication Tables 1 to 10body {font-family: Verdana, serif;} <?php
// Print out multiplication tables 1-10 with the variables x and
y, where x represents each of the integers 1-10 and y represents each of
the integers 1-10.
// The for loop is used to set the table for a specified number of
iterations, in this case so that each integer 1-10 will be multiplied by
the second integer 1-10.
for ($x = 1; $x <=10; $x++){
$y = 1;
// The while loop is nested inside the for loop in order to ensure that
each of the integers 1-10 represented by x is multiplied by each of the
integers 1-10 represented by y (until the condition is false).
while (y <=10){
$product = $x * $y;
print "$x times $y = $product\n";
$y++;
}
}
?>
Thanks so much to anyone willing to help. ???