我想从我的数据库的一个表中读取数据(从页面中选择)并根据插入将它们复制到多个表中。当我复制到一个或另一个表时,我的脚本工作正常,但是当我像下面这样运行它时,它只会将数据复制到第一个表中。你们能帮帮我吗?
<?php
// Pripojenie na databazu s overenim pripojenia
$con = mysql_connect('localhost:8501' , 'root', '');
if(!$con) {
die("Nepripojene ".mysql_error());
}
// Vyber databazy ikarus2 s overenim vyberu
$db = mysql_select_db('ikarus2',$con);
if(!$db) {
die('Ziadny pristup k db ikarus2!'.mysql_error());
}
// MySQL SELECT from pages
$result = mysql_query('SELECT uid, t3ver_oid, t3ver_id, t3ver_wsid, t3ver_label, t3ver_state, t3ver_stage,
t3ver_count, t3ver_tstamp, t3_origuid, tstamp, crdate, cruser_id,
title, hidden, starttime, endtime, deleted, subtitle, nav_title, media, keywords, description, abstract, author, author_email,
tx_impexp_origuid, tx_realurl_pathsegment, doktype, url, urltype, shortcut, shortcut_mode, t3ver_move_id, sorting,
layout, fe_group FROM pages',$con);
// MySQL INSERT into pages_language_overlay
while ($row = mysql_fetch_array($result)){
$insertoverlay = "INSERT INTO pages_language_overlay( pid, t3ver_oid, t3ver_id, t3ver_wsid, t3ver_label, t3ver_state, t3ver_stage,
t3ver_count, t3ver_tstamp, t3_origuid, tstamp, crdate, cruser_id, sys_language_uid, title, hidden, starttime, endtime,
deleted, subtitle, nav_title, media, keywords, description, abstract, author, author_email, tx_impexp_origuid, tx_realurl_pathsegment,
doktype, url, urltype, shortcut, shortcut_mode)
VALUES ('$row[0]','$row[1]','$row[2]','$row[3]','$row[4]','$row[5]','$row[6]','$row[7]','$row[8]',
'$row[9]','$row[10]','$row[11]','$row[12]','5', '$row[13]','$row[14]','$row[15]','$row[16]','$row[17]','$row[18]',
'$row[19]','$row[20]','$row[21]','$row[22]','$row[23]','$row[24]','$row[25]','$row[26]','$row[27]','$row[28]',
'$row[29]','$row[30]','$row[31]','$row[32]')";
mysql_query($insertoverlay,$con);
}
// MySQL INSERT into tt_content
while ($row = mysql_fetch_array($result)){
$insertcontent = "INSERT INTO tt_content( pid, t3ver_oid, t3ver_id, t3ver_wsid, t3ver_label, t3ver_state, t3ver_stage, t3ver_count,
t3ver_tstamp, t3ver_move_id, t3_origuid, tstamp, crdate, cruser_id, hidden, sorting, media, layout,
deleted, starttime, endtime, fe_group, sys_language_uid, tx_impexp_origuid)
VALUES ('$row[0]','$row[1]','$row[2]','$row[3]','$row [4]','$row[5]','$row[6]','$row[7]','$row[8]',
'$row[33]','$row[9]','$row[10]','$row[11]','$row[12]','$row[14]','$row[34]','$row[20]','$row[35]','$row[17]',
'$row[15]','$row[16]','$row [36]','5','$row[26]')";
mysql_query($insertcontent,$con);
}
?>