▼  Site Navigation Main Articles News Search  ▼  Anime + Manga Anime Reviews Anime Characters Gallery Screenshots Manga Reviews  ▼  Misc Links to Webcomics Bible Quotes About Older Musings
site version 7.3
MySQL –– combine tables
written by: admin


Date Written: 11/14/08 Last Updated: 1/14/24

The following will gather the contents of one table and insert it at the end of another table.  Make sure the field names are the same, but even if they are not it can be easily remedied.  Make sure that you put the right content type into the right fields.
<?php
include 'include/db.php';
$query = "SELECT * FROM news";
$result = mysqli_query($query,$conn);
$numrows = mysqli_num_rows($result);
$query = "SELECT * FROM news2";
$result1 = mysqli_query($query,$conn);
while ($row = mysqli_fetch_array($result1)){
$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 = mysqli_query($db);
}
echo "all done";
?>


TAGS: mysql
copyright 2005–2024