2016-05-08 2 views
-1

Wie kann man machen, wenn die Antwort richtig ist, erscheint eine Meldung, dass die Antwort richtig ist ?? Dies ist mein Versuch> Ich versuche zu machen (wenn) aber es ist falsch zurück, wenn die Antwort richtig ist >> Wie kann dieses Problem behoben werden Bitte Hilfe !!!Rückgabe falsch, wenn die Antwort korrekt ist, wie kann der Code in PHP reparieren?

<table dir="rtl"style="margin-right: 10px;" id="rounded-corner" summary="2007 Major IT Companies' Profit" style="margin-left:150px;"> 
 
    <thead> 
 
    </thead> 
 

 
    <tbody> 
 
\t 
 
<?php 
 

 
$query_run=mysql_query("select * from questions ORDER BY RAND() LIMIT 5"); 
 

 
while($row=mysql_fetch_array($query_run)) 
 
     { 
 
     $question = $row['question']; 
 
\t \t $ans = $row['ans']; 
 
\t \t $anstwo = $row['anstwo']; 
 
\t \t $correct_ans = $row['correct_ans']; 
 

 
?> 
 

 
    <tr> 
 
     <th colspan="3"width="211" class="rounded" scope="col">السؤال</th>   
 
\t </tr>   
 
\t \t <tr> 
 
\t \t <?php 
 
\t \t  
 
echo"<tr><td> <img src=question/$question width=100 hieght=100></td></tr>"; 
 
echo"<tr><td><label> 
 
    <input type=\"radio\" name=\"fb\" value=\"small\" /><img src=question/$ans width=100 hieght=100></label></td><td><label> 
 
    <input type=\"radio\" name=\"fb\" value=\"small\" /><img src=question/$anstwo width=100 hieght=100></label></td><td><label> 
 
    <input type=\"radio\" name=\"fb\" value=\"$correct_ans\" /><img src=question/$correct_ans width=100 hieght=100></label></td</tr><br>"; 
 
    
 
    ?> 
 
</tr> 
 
<?php 
 
} 
 
if (isset($_POST['submit'])) { 
 
    $value = $_POST; 
 

 
    if ($value == "$correct_ans") 
 
     echo "THAT ANSWER IS CORRECT"; 
 
    else 
 
     echo "THAT ANSWER IS WRONG!";} 
 
?> 
 

 
    </tbody> 
 
</table>

Antwort

0
if ($value == "$correct_ans") 
     echo "THAT ANSWER IS CORRECT"; 
    else 
     echo "THAT ANSWER IS WRONG!";} 

sollte

if ($value == $correct_ans) 
{ 
     echo "THAT ANSWER IS CORRECT"; 
}else 
{ 
     echo "THAT ANSWER IS WRONG!"; 
} 

"$ correct_ans" sein, wie geschrieben von Ihnen eine Zeichenfolge keine Variable ist.

+0

nein funktioniert nicht :(:( – mona

+0

Können Sie var_dump ($ value) und sehen, was es zurückgibt? – azdonald

Verwandte Themen