PHP Script to copy tables from SQL

Discussion in 'PHP' started by JimKarvo, Dec 29, 2007.

  1. #1
    Hello! I want to copy user's accound of mySQL (eg sqlname = 'users') to another, that name is 'mailing'

    Could it possible?
    Can anyone helps me?

    Yours,
    JimKarvo
     
    JimKarvo, Dec 29, 2007 IP
  2. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you can do that from phpMyAdmin, if you login as root, and move tables.. check it out
     
    DarkMindZ, Dec 29, 2007 IP
  3. JimKarvo

    JimKarvo Peon

    Messages:
    151
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, I can do that, but I would prefer something automatically! I mean to run a file and transfer the tables.. :S
     
    JimKarvo, Dec 29, 2007 IP
  4. hip_hop_x

    hip_hop_x Active Member

    Messages:
    522
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #4
    you will need to create the database structure(all the tables, and their structure),then select each data from each table and insert it in the new database.
    I haven't tested, but I think the bellow code will work.

    $query=mysql_query("SELETC * FROM `table1` LIMIT 1000");
    while($row=mysql_fetch_array($query)){
    //you establish a 2nd connection with the remote host/localhost
    $newquery=mysql_query("INSERT INTO `table1` VALUES('".$row['data1']."', '".$row['data2']."')");
    }
    PHP:
     
    hip_hop_x, Dec 29, 2007 IP