title: How to copy all the tables from one database to another database using php?
body: <p>I need to copy all the values of a table programatically from one database to another.I highly prefer using php. How do i achieve this?</p>
  
  <p>I found a particular code:</p>
  
  <pre><code>$sql1 = "DELETE FROM Kunthanahali.justshawarma_aauth_groups;";
  $result1 = $conn-&gt;query($sql1);
  
  $sql2 = "INSERT INTO Kunthanahali.justshawarma_aauth_groups SELECT * FROM justshawarmapos.justshawarma_aauth_groups;";
  $result2 = $conn-&gt;query($sql2);
  </code></pre>
  
  <p>This code is working fine.But the problem is I have around 50 tables in my database.Is there a way to truncate the second database and create tables and copy values from the first database?</p>
  
  <p><strong>I know there is a option inside phpmyadmin. But i want to do this programatically.</strong>
  I want to achieve this because i am creating an point of sale system where the point of sale system is present in the localhost and the analytics is viewed online in a website.I need to copy the tables and its data periodically to the online database.</p>