Greetings

i'm sorry for bother you guys with my questions but i'm in the process of learning php and they say if you want to be the best learn from the best :)

what i want to know is how can i copy a column "field" from a Table lets say A then place this filed at another Table thats B after the copy process is done the filed well be deleted automatically from table A

hope you can help me with this :)

i don't know anything about copying process so i can't post the code i'm working on , i'll put my connection code maybe it will save some of your time....

<?php 

$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "el";


@mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect"); 
@mysql_select_db("$db_name") or die ("No database found");
echo"you are connected to the DB";

?>

You can refer to this idea.
Lets say you have name, address and id to your table both table a and b.

<?php

 $query = mysql_query("SELECT * FROM table_a");
 while($result = mysql_fetch_array($query))
 {
   $name = $result['name'];
   $address = $result['address'];
   $id = $result['id'];

   mysql_query("INSERT INTO table_b (name,address,id) values('$name','$address','$id')");
   mysql_query("DELETE FROM table_a where id='".$id."'");
 }
 
?>

once the loop finished, all the data on table_a will transfer to table_b.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.