Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Fill in Questions

Posted on 2002-04-01
2
Medium Priority
?
254 Views
Last Modified: 2013-12-03
please correct the following code, i can't seem to know what's wrong with it:
<html>
<head>
<body>
<font size="5">Here is your question    </font> (The correct answer is in <font color="#008000"> green </font>)
<BR>
<font face="Arial">
<BR><BR><BR>
<? for ($m=0;$m<strlen($Content);$m++) {
    if ($Content[$m] != "#")
    echo $Content[$m];
    elseif
    ?><INPUT TYPE="text" NAME="answer" VALUE="" SIZE="15" ><?
}
?>
<BR><BR>
<?
  if ($answer1 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer1;?> </font>
<BR>
<?}
  if ($answer2 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer2;?> </font>
<BR>
<?}
  if ($answer3 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer3;?> </font>
<BR>
<?}
  if ($answer4 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer4;?> </font>
<BR>
<?}
?>
<BR><BR>Difficulty Level             <font color="#008000"><? echo $Difficulty_Level ?></font>
<BR>Restricted Question    <font color="#008000">
<? if ($Private=="Y")
{
?>
Yes
<? } else {
?>
No
<?
}
?>
</font>
</body>
</head>
</html>
0
Comment
Question by:almaha
2 Comments
 
LVL 5

Expert Comment

by:andriv
ID: 6910885
Your error is with the elseif, if you use elseif you need an argument:

elseif(codition)

Change it to:

else{

This way it's either the if or the else.

0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 200 total points
ID: 6912504
Check this code out,

<html>
<head>
<body>
<font size="5">Here is your question    </font> (The correct answer is in <font color="#008000"> green
</font>)
<BR>
<font face="Arial">
<BR><BR><BR>
<?php
     
function put_answer($answer)
{
     print "<font color=\"#008000\" face=\"Arial\"> $answer3</font>";
}
     
?>
<?
     for ($m=0;$m<strlen($Content);$m++)
     {
        if ($Content[$m] != "#")
               echo $Content[$m];
        elseif(YOUR CONDTION HERE) ///////// You need to Provide your condition here. Or choose else, instead of elseif
     {
             ?><INPUT TYPE="text" NAME="answer" VALUE="" SIZE="15" ><?
     }
?>
<BR><BR>
<?
 if (!empty($answer1))
          put_answer($answer1);

 if (!empty($answer2))
          put_answer($answer2);

 if (!empty($answer3))
          put_answer($answer3);

 if (!empty($answer4))
          put_answer($answer4);
?>

<BR><BR>Difficulty Level             <font color="#008000"><? echo $Difficulty_Level ?></font>
<BR>Restricted Question    <font color="#008000">
<?
     
     if ($Private=="Y")
          print "Yes";
     else
          print "No";

?>


</font>
</body>
</head>
</html>

You need to specify elseif condition.

Specify that or I guess you just need to use ELSE. instead of Elseif.

You are escaping in/out of PHP mode bit too much and unnecessarily. I mean you just want to print one HTML and you are escaping to HTML for that.

See this code, it is much more organized and readable.

JD
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question