我是php新手。我想创建一个在线toefl测试。现在我想计算用户的最终得分。我想从数据库的两个表中获取数据,即score_structure表和score_listening表。
我想从score_structure表和score_listening表中获取分数,然后计算它们。但是当我运行它时,从表score_Sturcute得分并且表score_listening没有进入。请帮助我
这是我的代码:
<? php
$email = $_SESSION['email'];
$final="SELECT score_listening.score_list,score_structure.score_struct FROM score_listening, score_structure WHERE score_listening.email = score_structure.email
AND score_listening.email = $email";
$ex=mysql_query($final);
$data=mysql_fetch_array($ex);
$ScoreListening=$data['score_list'];
$ScoreStructure=$data['score_struct'];
$SkorAkhir = (($ScoreListening+ $ScoreStructure+ $score)/3) * 10;
$simpan = "INSERT INTO score_reading VALUES ('$email', '$score')";
$NA = "INSERT INTO final_score VALUES ('$email', '$ScoreListening', '$ScoreStructure', '$score', '$FinalScore')";
if(mysql_query($simpan) && mysql_query($NA)){
header("location:index.php");
}else {
echo mysql_error();
}
}
?>