Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

php help.


ghost's Avatar
0 0

Ok so when they select a number between 1-8 on the previous page before this one they select how many different <option></option> 's they get between the select tag. Like if it syas case "2" they get two <option> tags being echo'd on the page. Sadly this is not working and says i have a problem at line 15 where it has the first "echo "<select>…." Can someone hlep me… i really need to figure this out

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head>

<body> <form method="get" action="calculator.php"> <?php switch($number)

{ case "1"; echo "<select><option name="grade1" value="4">A</option> <option name="grade1" value="3">B</option> <option name="grade1" value="2">C</option> <option name="grade1" value="1">D</option> <option name="grade1" value="0">F</option> </select>"; break;

case &quot;2&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;3&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade3&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;

	case &quot;4&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade3&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade4&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;5&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade3&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade4&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade5&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;6&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade3&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade4&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade5&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade6&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;7&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade3&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade4&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade5&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade6&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	
	&lt;select&gt;&lt;option name=&quot;grade7&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;8&quot;;

	echo &quot;&lt;select&gt;&lt;option name=&quot;grade1&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade1&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade2&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade2&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade3&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade3&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&quot;grade4&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade4&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade5&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade5&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&quot;grade6&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade6&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	
	&lt;select&gt;&lt;option name=&quot;grade7&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade7&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		&lt;select&gt;&lt;option name=&quot;grade8&quot; value=&quot;4&quot;&gt;A&lt;/option&gt;
	&lt;option name=&quot;grade8&quot; value=&quot;3&quot;&gt;B&lt;/option&gt;
	&lt;option name=&quot;grade8&quot; value=&quot;2&quot;&gt;C&lt;/option&gt;
	&lt;option name=&quot;grade8&quot; value=&quot;1&quot;&gt;D&lt;/option&gt;
	&lt;option name=&quot;grade8&quot; value=&quot;0&quot;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
default:
	echo (&quot;Go back and do it again&quot;);

?> </form> </body> </html>


ghost's Avatar
0 0

What do you mean use a back slash?


ghost's Avatar
0 0

darthchocobo wrote: What do you mean use a back slash?

When you echo double quotes, you need a backslash to escape it (prevent it from ending the echo)

echo &quot;&lt;a href=&#92;&quot;php.php&#92;&quot;&gt;PHP&lt;/a&gt;&quot;;
?&gt;```
 
Is actually:
 
```markup&lt;?php
echo &quot;&lt;a href=&quot;php.php&quot;&gt;PHP&lt;/a&gt;&quot;;
?&gt;```
 
But, what would happen if you didn&#39;t use the backslashes? The echo would be cut off when the next double quote (unescaped) was used, and &#39;php.php&#39; with the rest of the line would just return a syntax error.

ghost's Avatar
0 0

for example what would i need to put backslashes around?


ghost's Avatar
0 0

darthchocobo wrote: for example what would i need to put backslashes around?

You place the backslash before the " to include the " in a PHP echo(). So if you wanted to echo a double quote you would use \" to echo the double quote. Do you see now?


ghost's Avatar
0 0

so i would put echo "<select><option name=\"grade1\" value=\"4\">A</option>… ?


ghost's Avatar
0 0

[quote]darthchocobo wrote: yes


ghost's Avatar
0 0

Refer to the PHP Manual for strings:

http://au2.php.net/types.string

You can also change those echo statements to single quoted (') strings, then you dont have to worry about problems with using double quotes (") in your output.

Obviously, there's a difference between using ' and ", so I suggest you read up on whichever is most appropriate for what you're trying to do.


ghost's Avatar
0 0

If i were to put single quotes around echo '….' then it would be all fine? But what if inside i have a value for osmething such as <option name="blah" value="vlah"></option> do i use double quotes or will i have to put the name="\blah"?


ghost's Avatar
0 0

darthchocobo wrote: If i were to put single quotes around echo '….' then it would be all fine? But what if inside i have a value for osmething such as <option name="blah" value="vlah"></option> do i use double quotes or will i have to put the name="\blah"?

From what you posted above using single quotes would be fine, you wouldn't have to change anything else. (ie, leave the double quotes inside the tags as they are)

Using ' is different to " though. One difference is that you cannot do variable expansion in single quoted strings. You dont have any variables in your echo statements, which is why I suggest using a single quoted string.

Read the PHP manual on strings if you're still unsure.


ghost's Avatar
0 0

Johnson wrote: Refer to the PHP Manual for strings:

http://au2.php.net/types.string

You can also change those echo statements to single quoted (') strings, then you dont have to worry about problems with using double quotes (") in your output.

Obviously, there's a difference between using ' and ", so I suggest you read up on whichever is most appropriate for what you're trying to do.

For one double quotes parse variables whereas single quotes don't.


ghost's Avatar
0 0

Ok so i fixed that problem and now it has an issue with line 316 which is the very last line. what could that mean?

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> <title>Untitled Document</title> </head>

<body> <form method='get' action='calculator.php'> <?php switch($number)

{ case "1": echo "<select><option name='grade1' value='4'>A</option> <option name='grade1' value='3'>B</option> <option name='grade1' value='2'>C</option> <option name='grade1' value='1'>D</option> <option name='grade1' value='0'>F</option> </select>"; break;

case &quot;2&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;3&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade3&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;

	case &quot;4&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade3&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade4&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;5&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade3&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade4&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade5&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;6&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade3&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade4&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade5&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade6&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;7&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade3&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade4&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade5&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade6&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	
	&lt;select&gt;&lt;option name=&#39;grade7&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
	
	case &quot;8&quot;:

	echo &quot;&lt;select&gt;&lt;option name=&#39;grade1&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade1&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade2&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade2&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade3&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade3&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		
	&lt;select&gt;&lt;option name=&#39;grade4&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade4&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade5&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade5&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	&lt;select&gt;&lt;option name=&#39;grade6&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade6&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
	
	&lt;select&gt;&lt;option name=&#39;grade7&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade7&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;
	
		&lt;select&gt;&lt;option name=&#39;grade8&#39; value=&#39;4&#39;&gt;A&lt;/option&gt;
	&lt;option name=&#39;grade8&#39; value=&#39;3&#39;&gt;B&lt;/option&gt;
	&lt;option name=&#39;grade8&#39; value=&#39;2&#39;&gt;C&lt;/option&gt;
	&lt;option name=&#39;grade8&#39; value=&#39;1&#39;&gt;D&lt;/option&gt;
	&lt;option name=&#39;grade8&#39; value=&#39;0&#39;&gt;F&lt;/option&gt;
	&lt;/select&gt;&quot;;
	
	break;
default:
	echo &quot;Go back and do it again&quot;;

?> </form> </body> </html>


ghost's Avatar
0 0

Edit: I guess more than that one line was necessary. Nonetheless damn that gets annoying :@


ghost's Avatar
0 0

You forgot the } brace to close the switch statement, put it after the last echo statement.


ghost's Avatar
0 0

the line is the very last one its the blank one under the </html> thats what is confusing me


ghost's Avatar
0 0

Thank you guys so much for all your help and having patience with me!