PHP回应奇怪的人物

时间:2015-07-27 09:51:13

标签: php html

程序从2个数据库表中获取5个变量,并将它们相互比较。每个正确的匹配增加一个正确的变量。

我应该得到像#" 100%"而是得到"�%"和"?%"等或只是随机字符。

请参阅以下HTML页面摘录

<!DOCTYPE html> 
<html xmlns="w3.org/1999/xhtml"; xml:lang="en" lang="en"> 
<head> 
<meta charset="UTF-8" /> 
</head>
<body>
<?php

        $user = $_SESSION['currentUser'];

        $answerCheck1 = mysqli_query($conn,"SELECT * FROM tutorial_exam");
        $answerRowCheck1 = mysqli_fetch_array($answerCheck1);

        $answerCheck2 = mysqli_query($conn,"SELECT * FROM tutorials_test WHERE user_id='$user'");
        $answerRowCheck2 = mysqli_fetch_array($answerCheck2);

        $answerCheckT = mysqli_query($conn,"SELECT * FROM tutorials WHERE user_id='$user'");
        $answerRowCheckT = mysqli_fetch_array($answerCheckT);
        $total = $answerRowCheckT['exam'];
        if($total > 0){$total = $total ."%";}else{$total = '';}

        $counter1 = 1;
        $correct1 = 0;
        $userAnswer1 = '';
        $databaseAnswer1 = '';
        while($counter1 <= 5)
            {
                $index1 = 'q'.$counter1;
                $userAnswer1 = $answerRowCheck2[$index1];
                $databaseAnswer1 = $answerRowCheck1[$index1];
                if($userAnswer1 == $databaseAnswer1)
                {
                    $correct1 = $correct1 + 1;
                    //$correct = $answerRow[$counter];
                }
                $counter1 = $counter1 + 1;
            }
        $mark1 = $correct1 / 5 * 100;
        $mark1 = round($mark1,0);

        echo $mark1 . "%";

?>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

只是一个建议,请尝试在页面的<head>部分添加此内容:

<meta charset="utf-8">

答案 1 :(得分:0)

我们使用Server2Go从记忆棒运行我们的系统,似乎修复它的是更新server2Go系统上的PHP版本。

我们在另一个Stack Overflow线程中找到了如何做到这一点:Other answer link