0

i am new in php. I want to create a online toefl test. Now I want to calculate the final score of the user. I want to take the data from the two tables of the database, that is score_structure table and score_listening table.

I would like to take the score from the score_structure table and score_listening table and then count them. but when i run it, score from table score_Sturcute and table score_listening did not get in. please help mee

this is my code:

<? 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();
              }
              }
          ?>
cassie
  • 13
  • 4
  • To get the count of both tables: Count the first table and set a variable, `$a`, equal to the count. Then set another variable, `$b`, equal to table two's count. Then set the final variable, `$c`, equal to `$a + $b`. Then just echo out `$c` to see the final result. – GROVER. Jun 02 '16 at 00:49
  • what you get after run it ? any error ? –  Jun 02 '16 at 02:04
  • 1st issue - `$email` is a string, so it needs to be quoted -> `... AND score_listening.email = '$email'` – Sean Jun 02 '16 at 02:29

0 Answers0