title: PHP - Store & Calculate the total mark from radio input
body: <p>I have designed a small web-based system that have a school evaluation form to ask specific users who can access the system" some questions and the input will be a radio type ( 1 or 2 or 3 or 4)! 
  the code is working and can inserts the input into the database but i don't know the correct query to calculate the total mark and store it in the database, this is currently working code below:</p>
  
  <pre><code>    &lt;?php
  
     session_start();
     $Load=$_SESSION['login_user'];
     include('../connect.php');
     $sql= "Select name from student where ID='$Load'";
     $username = mysql_query($sql);
      $id=$_SESSION['login_user'];
  
                  if (isset($_POST['submit']))
  
  {  
  
     $v1 = $_POST['v1'];
     $v2 = $_POST['v2'];
     $v3 = $_POST['v3'];
     $total = $_POST['total'];
  
   mysql_query("INSERT into Form1 (P1,P2,P3,TOTAL)
   values('$v1','$v2','$v3','$total')") or die(mysql_error());
   header("Location: mark.php");
   }
  
  
  ?&gt;
  
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;?php
  
  
  if(!isset($_SESSION['login_user']))
  
  header("Location:index.html");
  
  
  
  ?&gt;
    &lt;title&gt;Q&amp;A Form&lt;/title&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
      &lt;center&gt;&lt;form method="post" action=""  &gt;
  
      &lt;table style="width: 20%" &gt;
          &lt;tr&gt;
      &lt;th&gt; Criteria &lt;/th&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th&gt; Excellent &lt;/th&gt;
      &lt;td &gt;  4 &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th &gt; Good &lt;font size="3" &gt; &lt;/font&gt;&lt;/th&gt;
      &lt;td&gt;  3 &lt;font size="4" &gt; &lt;/font&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th &gt; Average &lt;font size="3" &gt; &lt;/font&gt;&lt;/th&gt;
      &lt;td &gt;  2 &lt;font size="4" &gt; &lt;/font&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;th &gt; Poor &lt;font size="3" &gt; &lt;/font&gt;&lt;/th&gt;
      &lt;td &gt;  1 &lt;font size="4" &gt; &lt;/td&gt;
      &lt;/tr&gt;
  
  
  
  
  &lt;font size='4'&gt;
      &lt;table style="width: 70%"&gt;
          &lt;tr&gt;
  &lt;th &gt; School Evaluation &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  
  &lt;tr&gt;
  &lt;th &gt; Criteria &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 4&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 3&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 2&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
              &lt;th&gt; 1&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  
          &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th&gt; Your attendance&lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "4"    checked = "checked" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "3"     /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "2"     /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v1" value = "1"     /&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;th &gt; Your grades  &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "4"    checked = "checked" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "3"     /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "2"     /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v2" value = "1"     /&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;th &gt;Your self-control &lt;font size="4" &gt; &lt;/font&gt;&lt;/th&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "4"    checked = "checked" /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "3"     /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "2"     /&gt;&lt;/td&gt;
  &lt;td&gt;  &lt;input type="radio" name ="v3" value = "1"     /&gt;&lt;/td&gt;    
  &lt;/tr&gt;       
  
  
          &lt;/tr&gt;
      &lt;/table&gt;
  
  
      &lt;br&gt;
      &lt;a href="evaE.php"&gt;  &lt;td&gt;&lt;input type="submit" name="submit" value="Submit"&gt;
  
      &lt;input type="reset" name="clear" value="clear" style="width: 70px"&gt;&lt;/td&gt;
  &lt;?php
  $total = $v1+ $v2 + $v3;
  
  ?&gt;  
  
  
   &lt;/form&gt; 
  &lt;/center&gt;
  &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>i used this query but it doesn't work out .. any help please?</p>
  
  <pre><code> &lt;?php
      $total = $v1+ $v2 + $v3;
  
      ?&gt;  
  </code></pre>