www.webdeveloper.com
Results 1 to 5 of 5

Thread: select option display

  1. #1
    Join Date
    May 2003
    Posts
    144

    select option display

    Hi! I was trying to make a survey or questionaire script but got stuck when I got there
    can anyone pinpoint the mistake I am making here?
    Thanks in advance!

    question.php
    PHP Code:
    <form action="result.php" method="post">
    <
    input blahblah><br><br>

    <select name="hh">
    <
    option value="nonehh">----</option>
    <
    option value="have">have</option>
    <
    option value="has">has</option>
    </
    selectbeen trying... 
    result.php
    PHP Code:
    Please correct the sentences and questions into correct form.<br>

    <?php if($have==$have)
    {echo
    "<font color='black' style='text-decoration:underline;'>have</font> ";}        
    elseif(
    $has==$has
        {echo 
    "<font color='red'> has </font>";}
               else
        { echo 
    "<font color='red'>_____</font>";}?>

    been trying...
    Learning never ends!

  2. #2
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    PHP Code:
    Please correct the sentences and questions into correct form.<br>
    I
    <?php 
    $hh 
    $_POST['hh'];

    if(
    $hh == "have"){
        echo(
    "<font color='black' style='text-decoration:underline;'>have</font> ");
    }elseif(
    $hh == "has"){
        echo(
    "<font color='red'> has </font>");
    }else{
        echo(
    "<font color='red'>_____</font>");
    }
    ?>

    been trying...

  3. #3
    Join Date
    May 2003
    Posts
    144
    thanks! It works perfectly.
    Learning never ends!

  4. #4
    Join Date
    May 2003
    Posts
    144
    just one more addition. I'd like to grade their answer.

    when I did like this:
    PHP Code:
    <?php
    $am 
    $_POST['am']="1";
    $is $_POST['is']="1";
    $total $am $is;
    echo 
    "The total is - <b>".$total."</b>.";

    I got the total scoreBut can't think of how I can grade their answers.
    ?>
    here's the script which I've been trying to work it on
    PHP Code:
    <?
    $am 
    $_POST['am'];
    $is $_POST['is'];
    $are $_POST['are'];
    $was $_POST['was'];
    $were $_POST['were'];
    $be $_POST['be'];
    $reading1 $_POST['reading1'];
    $reading2 $_POST['reading2'];
    $readingpast $_POST['readingpast'];
    $readingpast1 $_POST['readingpast1'];
    $readingpast2 $_POST['readingpast2'];
    $readingfuture $_POST['readingfuture'];
    $readingfuture1 $_POST['readingfuture1'];
    $readingfuture2 $_POST['readingfuture2'];
    $haveto1 $_POST['haveto1'];
    $haveto2 $_POST['haveto2'];
    $havetopast $_POST['havetopast'];
    $havetopast1 $_POST['havetopast1'];
    $havetopast2 $_POST['havetopast2'];
    $havetofuture $_POST['havetofuture'];
    $havetofuture1 $_POST['havetofuture1'];
    $havetofuture2 $_POST['havetofuture2'];
    $canhelp1 $_POST['canhelp1'];
    $canhelp2 $_POST['canhelp2'];
    $canhelppast $_POST['canhelppast'];
    $canhelppast1 $_POST['canhelppast1'];
    $canhelppast2 $_POST['canhelppast2'];
    $canhelpfuture $_POST['canhelpfuture'];
    $canhelpfuture1 $_POST['canhelpfuture1'];
    $canhelpfuture2 $_POST['canhelpfuture2'];

    $have $_POST['have'];
    $has $_POST['has'];
    $s1 $_POST['s1'];
    $s2 $_POST['s2'];
    $d1 $_POST['d1'];
    $d2 $_POST['d2'];
    $can $_POST['can'];
    $could $_POST['could'];
    $beableto $_POST['beableto'];
    $ableto $_POST['ableto'];
    $amoption $_POST['amoption'];
    $wasoption $_POST['wasoption'];

    $hh $_POST['hh'];
    $ss $_POST['ss'];
    $dd $_POST['dd'];
    $cc $_POST['cc'];
    $ab $_POST['ab'];
    $aw $_POST['aw'];

    ?>


    <form action="quiz1result.php" method="POST">
    <h1>Quiz I</h1>
    1. Please write down the Be-Verbs.<br>
    *<input type="text" name="am" value="<?php echo $am;?>">
    <?php if($am =="am") {echo"Correct! The answer is: am.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: am.</font>";}?><br>
    *<input type="text" name="is" value="<?php echo $is;?>">
    <?php if($is == "is") {echo"Correct! The answer is: is.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: is</font>";}?><br>
    *<input type="text" name="are" value="<?php echo $are;?>">
    <?php if($are =="are") {echo"Correct! The answer is: are.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: are</font>";}?><br>
    *<input type="text" name="was" value="<?php echo $was;?>">
    <?php if($was =="was") {echo"Correct! The answer is: was.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: was</font>";}?><br>
    *<input type="text" name="were" value="<?php echo $were;?>">
    <?php if($were =="were") {echo"Correct! The answer is: were.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: were</font>";}?><br>
    *<input type="text" name="be" value="<?php echo $be;?>">
    <?php if($be =="be") {echo"Correct! The answer is: be.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: be</font>";}?><br>
    <hr noshade><br>

    2. Are you reading books? <br>
    <textarea cols="50" rows="2" name="reading1"><?php echo $reading1;?></textarea>
    <?php if($reading1 =="Yes, I am reading books.") {echo"Correct! The answer is: Yes, I am reading books.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: Yes, I am reading books.</font>";}?><br><br>
    <textarea cols="50" rows="2" name="reading2"><?php echo $reading2;?></textarea>
    <?php if($reading2 =="No, I am not reading books.") {echo"Correct! The answer is: No, I am not reading books.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: No, I am not reading books.</font>";}?><br><hr noshade><br>

    3. Are you reading books? Please write it in Past form.<br>
    <textarea cols="50" rows="2" name="readingpast"><?php echo $readingpast;?></textarea>
    <?php if($readingpast =="Were you reading books?"
    {echo
    "Correct! The answer is: Were you reading books?";}
    else
    {echo
    "<font color='red'>Sorry, Wrong answer! The answer is: Were you reading books?</font>";}?>
    <br><br>
    <textarea cols="50" rows="2" name="readingpast1"><?php echo $readingpast1;?></textarea>
    <?php if($readingpast1 =="Yes, I was reading books."
    {echo
    "Correct! The answer is: Yes, I was reading books.";}
    else
    {echo
    "<font color='red'>Sorry, Wrong answer! The answer is: Yes, I was reading books.</font>";}?>
    <br><br>
    <textarea cols="50" rows="2" name="readingpast2"><?php echo $readingpast2;?></textarea>
    <?php if($readingpast2 =="No, I was not reading books."
    {echo
    "Correct! The answer is: No, I was not reading books.";}
    else
    {echo
    "<font color='red'>Sorry, Wrong answer! The answer is: No, I was not reading books.</font>";}?><br>
    <hr noshade><br>

    4. Are you reading books? Please write it in Future form.<br>
    <textarea cols="50" rows="2" name="readingfuture"><?php echo $readingfuture;?></textarea>
    <?php if($readingfuture =="Will you be reading books?"
    {echo
    "Correct! The answer is: Will you be reading books?";}
    else
    {echo
    "<font color='red'>Sorry, Wrong answer! The answer is: Will you be reading books?</font>";}?>
    <br><br>
    <textarea cols="50" rows="2" name="readingfuture1"><?php echo $readingfuture1;?></textarea>
    <?php if($readingfuture1 =="Yes, I will be reading books."
    {echo
    "Correct! The answer is: Yes, I will be reading books.";}
    else
    {echo
    "<font color='red'>Sorry, Wrong answer! The answer is: Yes, I will be reading books.</font>";}?>
    <br><br>
    <textarea cols="50" rows="2" name="readingfuture2"><?php echo $readingfuture2;?></textarea>
    <?php if($readingfuture2 =="No, I will not be reading books.."
    {echo
    "Correct! The answer is: No, I will not be reading books.";}
    else
    {echo
    "<font color='red'>Sorry, Wrong answer! The answer is: No, I will not be reading books.</font>";}?><br>
    <hr noshade><br>

    5. Please correct the sentences and questions into correct form.<br>
    <?php 
    $hh 
    $_POST['hh']; 

    if(
    $hh == "have"){ 
        echo(
    "<font color='black' style='text-decoration:underline;'>have</font> "); 
    }elseif(
    $hh == "has"){ 
        echo(
    "<font color='red'> has </font>"); 
    }else{ 
        echo(
    "<font color='red'>_____</font>"); 

    ?> 
    to study because I want to become a high school <?php 
    $ss 
    $_POST['ss']; 

    if(
    $ss == "student"){ 
        echo(
    "<font color='black' style='text-decoration:underline;'>student</font> "); 
    }elseif(
    $ss == " students "){ 
        echo(
    "<font color='red'> students </font>"); 
    }else{ 
        echo(
    "<font color='red'>_______</font>"); 

    ?> . <?php 
    $dd 
    $_POST['dd']; 

    if(
    $hh == "Do"){ 
        echo(
    "<font color='black' style='text-decoration:underline;'>Do</font> "); 
    }elseif(
    $hh == "Does"){ 
        echo(
    "<font color='red'> Does </font>"); 
    }else{ 
        echo(
    "<font color='red'>_____</font>"); 

    ?>  your friends have to study, too? My friend,<br> John, studies everyday and he <?php 
    $cc 
    $_POST['cc']; 

    if(
    $cc == "can"){ 
        echo(
    "<font color='black' style='text-decoration:underline;'>can</font> "); 
    }elseif(
    $cc == "could"){ 
        echo(
    "<font color='red'> could </font>"); 
    }else{ 
        echo(
    "<font color='red'>_______</font>"); 

    ?>  study Math yesterday. Will you <?php 
    $ab 
    $_POST['ab']; 

    if(
    $ab == "be able to"){ 
        echo(
    "<font color='black' style='text-decoration:underline;'>be able to</font> "); 
    }elseif(
    $ab == "able to"){ 
        echo(
    "<font color='red'> able to </font>"); 
    }else{ 
        echo(
    "<font color='red'>__________</font>"); 

    ?>  sing tomorrow? I <?php 
    $aw 
    $_POST['aw']; 

    if(
    $aw == "was"){ 
        echo(
    "<font color='black' style='text-decoration:underline;'>was</font> "); 
    }elseif(
    $aw == "am"){ 
        echo(
    "<font color='red'> am </font>"); 
    }else{ 
        echo(
    "<font color='red'>____</font>"); 

    ?>  busy yesterday.<br>
    <br>
    <a href="/english/quiz1.php">Click here to take one more time</a>
    <br><br>
    <?php
    $total 
    $hh $ss $dd $cc $ab $aw $am $is $are $was $were $be 
             
    $reading1 $reading2 $readingpast $readingpast1 $readingpast2
             
    $readingfuture $readingfuture1 $readingfuture2;
    echo 
    "The total score is -<b> ".$total.".</b>";
    ?>
    Last edited by Michaelttkk; 09-13-2007 at 07:51 PM.
    Learning never ends!

  5. #5
    Join Date
    May 2003
    Posts
    144
    I figured it out to a certain level

    PHP Code:

    1. Please write down the Be-Verbs.<br> 
    *<input type="text" name="am" value="1">
    <?php if($am =="am") {echo"Correct! The answer is: am.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: am.</font>";}?><br> 
    *<input type="text" name="is" value="1"> 
    <?php if($is == "is") {echo"Correct! The answer is: is.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: is</font>";}?><br> 
    *<input type="text" name="are" value="1">
    <?php if($are =="are") {echo"Correct! The answer is: are.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: are</font>";}?><br> 
    *<input type="text" name="was" value="1"> 
    <?php if($was =="was") {echo"Correct! The answer is: was.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: was</font>";}?><br> 
    *<input type="text" name="were" value="1"> 
    <?php if($were =="were") {echo"Correct! The answer is: were.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: were</font>";}?><br> 
    *<input type="text" name="be" value="1"> 
    <?php if($be =="be") {echo"Correct! The answer is: be.";}else{echo"<font color='red'>Sorry, Wrong answer! The answer is: be</font>";}?><br> 
    <hr noshade><br> 
    <?php
    $num1 
    1;$num2 1;$num3 1;$num4 1;$num5 1;$num6 1;
    if(
    $am=am) { $num1}else{echo "nothing";}
    if(
    $is=is)  { $num2}else{echo "nothing";}
    if(
    $are=are)  { $num3}else{echo "nothing";}
    if(
    $was=was)  { $num4}else{echo "nothing";}
    if(
    $were=were)  { $num5}else{echo "nothing";}
    if(
    $be=be)  { $num6}else{echo "nothing";}

    $total $num1$num2 $num3 $num4 $num5 $num6;
    echo 
    $total;
    ?>
    just that all the textarea should be changed to input

    any suggestion is appreciated
    Last edited by Michaelttkk; 09-15-2007 at 04:36 AM.
    Learning never ends!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles