title: How to UPDATE record in two different tables using PDO?
body: <p>I have a page called update.php and what i want to do is that i want to update a record a record in two tables at the same time.what i have here now is just updating in a single table, can anyone please help me with it?</p>
  
  <p>****here is my code for class.user.php**</p>
  
  <pre><code>public function update($user_id,$username,$password,$province)
  {
  try
  {
    $stmt=$this-&gt;db-&gt;prepare("UPDATE login SET  username=:username,password=:password,province=:province WHERE user_id=:user_id");
    $stmt-&gt;bindparam(":username",$username);
    $stmt-&gt;bindparam(":password",$password);
    $stmt-&gt;bindparam(":province",$province);
    $stmt-&gt;execute();
  
    return true;
  }
  catch(PDOException $e)
  {
    echo $e-&gt;getMessage();
    return false;
  }
  }
  </code></pre>
  
  <p><strong>and here is now for update.php</strong></p>
  
  <pre><code>include_once 'dbconfig.php';
  
  if(isset($_POST['btn-update']))
      {
      $ID = $_GET['ID'];
      $username = $_POST['username'];
      $password = $_POST['password'];
      $province = $_POST['province'];
  
  if($crud-&gt;update($ID,$username,$password,$province))
      {
      echo "&lt;script type='text/javascript'&gt;alert('Successfully Updated!');&lt;/script&gt;";
      }
      else
      {
      echo "&lt;script type='text/javascript'&gt;alert('Updating Failed!'); &lt;/script&gt;";
      }
  }
      if(isset($_GET['ID']))
      {
      $ID = $_GET['ID'];
      extract($crud-&gt;getID($ID)); 
  }
  ?&gt;
  </code></pre>