title: Fetch PHP quiz result from MySQL table
body: <p>I have a multiple answer quiz created in PHP that posts the answers to a table in MySQL. There is no correct answer. There are 9 questions. The questions are radio buttons with names from a to i and the multiple answers are given the values from 1 to 4. This is the form:</p>
  
  <p><b>Avoiding paying the fare on public transport.<br></b>
      1. Never justified.<br>
      2. Rarely justified.<br>
      3. Sometimes justified.<br>
      4. Always justified.<br><br></p>
  
  <p>How do I fetch the result in these two forms:</p>
  
  <ol>
  <li>how many values of 1 or 2 or 3 or 4 out of all 9 questions have been selected. </li>
  <li>total sum of all the values selected.</li>
  </ol>
  
  <p>This is the table: </p>
  
  <pre><code>CREATE TABLE `tests`.`integrity` 
   ( `id` INT(11) NOT NULL AUTO_INCREMENT , 
     `name` VARCHAR(255) NOT NULL ,
     `q1` VARCHAR(255) NOT NULL ,
     `q2` VARCHAR(255) NOT NULL ,
     `q3` VARCHAR(255) NOT NULL ,
     `q4` VARCHAR(255) NOT NULL ,
     `q5` VARCHAR(255) NOT NULL ,
     `q6` VARCHAR(255) NOT NULL ,
     `q7` VARCHAR(255) NOT NULL ,
     `q8` VARCHAR(255) NOT NULL ,
     `q9` VARCHAR(255) NOT NULL ,
      PRIMARY KEY (`id`)) ENGINE = MyISAM;
  
     $sql = "INSERT INTO integrity (name, q1, q2, q3, q4, q5, q6, q7, q8, q9)   
             VALUES ('$value1', '$value2', '$value3', '$value4', '$value5',   
             '$value6', '$value7', '$value8', '$value9', '$value10')";
  </code></pre>
  
  <p>Example of the result could be: You scored 9 
  (in case the value selected to all the questions was 1 Never justified)</p>
  
  <p>Up to 15: 
  You are a very honest person who really wants to do the right thing.
  15 up to 20
  You are above average in integrity, but you do not mind bending the rules occasionally.
  20 up to 25
  You are relaxed about braking the rules when it suits you, but you are not fundamentally dishonest.
  25 plus You do not believe in living by the rules and find it easy to break them when it suits you.</p>