我有PHP MySQL的&煩惱。我已經來從DB1的表中的所有記錄,然後我不得不再次插入到DB2的表。檢索所有記錄,並插入到另一個表中形成另一個分貝
<?php
require_once 'includes/config.php';
include 'includes/header.php';
if(isset($_POST['go'])){
$query = mysql_query("SELECT id,username,password FROM $db_database1.account")
or die(mysql_error());
echo "Record ".mysql_num_rows($query)." retrieve";
while($result_row = mysql_fetch_array($query, MYSQL_ASSOC)){
$account_ID = $result_row['id'];
$username = $result_row['username'];
$password = $result_row['password'];
$query = mysql_query("INSERT INTO $db_database2.account(uid,username,password) VALUES('$account_ID','$username','$password')")
or die(mysql_error());
$selectId = mysql_insert_id();
}
}
mysql_close($conn);
?>
<div class="wrapper">
<div class="content">
<form method="post" action="<?PHP $_SERVER['PHP_SELF'];?>">
<input type="submit" name="go" value="Go" />
</form>
</div>
<?php include 'includes/footer.php';?>
根據這段代碼只插入了一條記錄。我怎樣才能插入所有檢索到的記錄?
-1前問一個數據庫備份**不是真正的問題**你真的需要一個答案。 – 2012-02-21 05:51:17