title: php mysql get variable data from database and calculate
body: <p>hello fellow overflower i have problem iwant to get variable data "$b ,$d, $f,$h" from database and then calculate it 
   here my example</p>
  
  <pre><code>&lt;?php
      $host="localhost";
      $username="root";
      $password="root";
      $db_name="cbrteh"
  
      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");
  
      $b= mysql_query("SELECT bobot FROM atribut where id= 1"); 
      ($row = mysql_fetch_assoc($b));
      $row["bobot"];
      $d= mysql_query("SELECT bobot FROM atribut where id= 2"); 
      ($row = mysql_fetch_assoc($d));
       $row["bobot"];
      $f= mysql_query("SELECT bobot FROM atribut where id= 3"); 
      ($row = mysql_fetch_assoc($f));
      $row["bobot"];
      $h= mysql_query("SELECT bobot FROM atribut where id= 4"); 
      ($row = mysql_fetch_assoc($h));
      $row["bobot"];
      $calc = $b+$d+$f+$h;
      echo $calc;
  </code></pre>
  
  <p>
  
  <p>is my script right 
  the value on database are 50,50,50,50 so the value must be 200
   but the value i got from echo $calc; is 22</p>