title: How to pull values from a table, calculate them and display the result on a page
body: <p><img src="https://i.stack.imgur.com/0U7Jw.jpg" alt="enter image description here"></p>
  
  <p>Hi, I'm doing a coding about risk analysis based on the image above (a table). Unfortunately I don't know how to translate the formula into a coding and display the result on a php page. Basically the formula involves multiplying of likelyhood * severity for each row, add between each of them and then average it (divide by 3). In short</p>
  
  <pre><code>result1 = (likelyhood1 * severity1)
  result2 = (likelyhood2 * severity2)
  result3 = (likelyhood3 * severity3)
  
  a = (result1 + result2 + result3) / 3
  </code></pre>
  
  <p>Result "a" is then displayed to the same php page (I'm using mysql database). </p>
  
  <p>I did try looking up for answers but to no avail. Here's where I'm stuck.</p>
  
  <pre><code>&lt;?php
  
  $con=mysqli_connect("localhost","root","","risk");
  // Check connection
  if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  $result = mysqli_query($con,"SELECT * FROM Persons");
  
  //$res1 = 
  
  mysqli_close($con);
  
  ?&gt;
  </code></pre>