I am going to be lazy in my answer.
Code:
<?php
include 'include/db.php';
$query = "SELECT * FROM news";
$result = mysql_query($query,$conn) or die ("Couldn't execute query.");
$numrows = mysql_num_rows($result);
$query = "SELECT * FROM news2";
$result1 = mysql_query($query,$conn) or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result1,MYSQL_ASSOC)){
$ID=$row['ID'];$ID=$ID+numrows+1;
$marriage=$row['energy'];$marriage=addslashes($marriage);
$date=$row['date'];
$db="INSERT INTO news (ID,marriage,date) VALUES ('$ID','$marriage','$date')";
$result = mysql_query($db) or die (mysql_error());
}
echo "all done";
?>
When combining tables make sure you are not mixing the data types of your columns, for example try not to put your text document into a datetime column. Make sure you backup your database as well or at least the tables you are working with.
The above script will take the content from the "news2" table and add it to the end of the table "news". The line that says $marriage=$row['energy']; is where a column of one name is changed to the correct name. It is not necessary, but I did it this way, because it made more sense to me this way.
The above is just an old script I had lying around. I have not had the need to use it in quite a while now.
The above should be enough for you to do what you need.
Bookmarks