Mattmueller
-
Posts
2 -
Joined
-
Last visited
Posts posted by Mattmueller
-
-
When doing the if else for the gender at steps 5, 6 and 7 he writes that the code should go
if (isset($_REQUEST['gender'])) {$gender = $_REQUEST['gender'];
if ($gender == 'M') {$greeting = '<p><b>Good Day, Sir!</b></p>';}
elseif ($gender == 'F') {$greeting = '<p><b>Good Day, Madam!</b></p>';}
else {$gender = NULL; echo '<p class="error">Gender Should be either "M" or "F"!</p>';}
else {$gender = NULL;
echo '<p class="error"> You forgot to select your gender!</p>';}Yet when you look at the example code in 2.4 it is written as:
if (isset($_REQUEST['gender'])) {$gender = $_REQUEST['gender'];
if ($gender == 'M') {echo '<p><b>Good Day, Sir!</b></p>';}
elseif ($gender == 'F') {echo '<p><b>Good Day, Madam!</b></p>';}
else {$gender = NULL; echo '<p class="error">Gender Should be either "M" or "F"!</p>';}
else {$gender = NULL;
echo '<p class="error"> You forgot to select your gender!</p>';}I seem to have missed why there is the difference in the two examples. Is one right and not the other? Does it matter which way you do it? Am i just totally over looking something? Wondered if i could get any help.
Why Is There A Difference In 2.4
in PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
Posted
I am not an expert or anything but i have the ebook on my computer and the two codes above are the two codes given. The one with "$greeting" is how you say to do it in step 6 and the one with "echo": is what the example shows. There is a possibility I am wrong, I am not rulling that out, but I wanted to know what i am missing.