PHP coding for copy one table to another table

         This is copy the  one table to another table.the PHP  bring to copy one table to another table.u can copy all data in the  table . u can easy way to copy the table     


syntax:

INSERT INTO new_table_name SELECT * FROM old_table_name;

       It select *    from old _table is  to select the old table and insert into new_table_name  to  copy the old table to new table .u want same field in both old table and new table  in database

Source Code:

 

<?php

$conn=mysql_connect("localhost", "root", ""); //connect database

mysql_select_db("database_name", $conn); //select database

$copy=mysql_query("INSERT INTO new_table_name SELECT * FROM old_table_name");

//copy the one table to another table
?>

No comments:

Post a Comment