title: Retrieve data from database and save it in a variable to do some calculation and diplay it
body: <p>I want to retrieve the last inserted id(id is in auto increment) from the database table named table facility and want to do some calculation(for example I am adding five now) and display the result on the screen. kindly help me I am not able to get this. </p>
  
  <pre><code> &lt;?php
  session_start();
  error_reporting(0);
  include('includes/config.php');
  if(strlen($_SESSION['alogin'])==0)
      {   
  header('location:index.php');
  }
  else{ 
  
  $sql="SELECT MAX(facilityid) FROM tblfacility ";
  $result=$dbh -&gt; query($sql);
  $row=$result-&gt;fetch(PDO::FETCH_ASSOC);
  echo "&lt;pre&gt;", print_r($row),"&lt;/pre&gt;";
  echo $result ;
  $code = $row-&gt;facilityid;
  $sampleid= $code +5;
  echo $sampleid;
  
  } 
  ?&gt;
  </code></pre>