PHP中的“if”条件变量

时间:2014-04-25 10:45:02

标签: javascript php jquery html mysql

我正在构建一个测验应用程序,工作正常现在决定添加"助推器" (为玩家提供帮助工具),我已经在这里发布了一个关于为计时器添加额外时间的问题,我仍在挖掘寻找解决方案,但现在没有运气..无论如何,现在这不是我的问题。 我开始研究第二个助推器:成功跳过一个问题(不丢分)

所以原始代码(在添加boost部分之前)是这样的:

<div id='question<?php echo $i;?>' class='cont'>
     <p class='questions' id="qname<?php echo $i;?>">
          <?php echo $i?>.<?php echo $result['question_name'];?></p>
               <input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' 
                     name='<?php echo $result['id'];?>'/>
               <?php echo $result['answer1'];?><br/>
               <input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' 
                     name='<?php echo $result['id'];?>'/>
               <?php echo $result['answer2'];?><br/>
               <input type="radio" value="3" id='radio1_<?php echo $result['id'];?>' 
                      name='<?php echo $result['id'];?>'/>
               <?php echo $result['answer3'];?><br/>
               <input type="radio" value="4" id='radio1_<?php echo $result['id'];?>' 
                      name='<?php echo $result['id'];?>'/>
               <?php echo $result['answer4'];?><br/>
               <input type="radio" checked='checked' style='display:none' value="5" 
                      id='radio1_<?php echo $result['id'];?>' 
                         name='<?php echo $result['id'];?>'/><br/>
               <button id='<?php echo $i;?>' class='next btn btn-success' type='button' >Next</button>

这就是积分的重点:

if(isset($_POST[1])){ 
$keys=array_keys($_POST);
$order=join(",",$keys);

//$query="select * from questions id IN($order) ORDER BY FIELD(id,$order)";
// echo $query;exit;

$response=mysql_query("select id,answer from questions where id IN($order) ORDER BY   FIELD(id,$order)")   or die(mysql_error());
$right_answer=0;
$wrong_answer=0;
$unanswered=0;
while($result=mysql_fetch_array($response)){
   if($result['answer']==$_POST[$result['id']]){
           $right_answer++;
       }else if($_POST[$result['id']]==5){
           $unanswered++;
       }
       else{
           $wrong_answer++;
       }

}

所以我的想法是添加一个名为&#34; Success skipe&#34;

的按钮
<button id='<?php echo $success;?>' class='skip btn btn-success' type='button'>Success Skip</button>

在计算正确的答案时,我试图制定一个条件,一旦点击此按钮,答案被认为是正确的,所以我添加了这个:

while($result=mysql_fetch_array($response)){
if($success){                          //Just added
$right_answer++;                   //this "if" condition
}

但它没有用,有什么不对?

0 个答案:

没有答案
相关问题