将数据从一个表移动到另一个表时出现查询错误:键“PRIMARY”的重复条目“0”我不在乎复制主键我希望每个表都有自己的主键-该表将只保存数据由人员处理、检查和发布,然后将其移至包含所有已处理数据的最终表格。
<basefont face="Arial">
<title>QA-1160 Search</title>
</head>
<body>
<?php
// include the page Header
include('header.php');
?>
<?php
//retrieve session data
echo $_SESSION['mnumber'];
echo "<P>";
$mnumber=$_SESSION['mnumber'];
$amnumber=$mnumber;
$mnumber=" '".$mnumber."' ";
// set database server access variables:
$host = "localhost";
$user = "test";
$pass = "test";
$db = "test";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database :)!");
// create query
$query = "insert into testingqa1160 (material, test, sample, frequency, stp, rtr, notes, usl, lsl) SELECT material, test, sample, frequency, stp, rtr, notes, usl, lsl FROM qa1160 WHERE material=";
$query=$query.$mnumber;
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// mysql_free_result($result);
// close connection
mysql_close($connection);
// clear session
session_unset();
session_destroy();
// load test data
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database :)!");
// create query
$query = "SELECT * FROM testingqa1160";
// $query=$query.$mnumber;
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<center><table cellpadding=5 border=1>";
echo "<tr>";
echo "<center>";
echo "<td>"."ID"."</td>";
echo "<td>"."Material"."</td>";
echo "<td>"."Test"."</td>";
echo "<td>"."Sample"."</td>";
echo "<td>"."Frequency"."</td>";
echo "<td>"."STP"."</td>";
echo "<td>"."Release"."</td>";
echo "<td>"."Notes"."</td>";
echo "<td>"."LSL"."</td>";
echo "<td>"."USL"."</td>";
echo "</center></tr>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "<td>".$row[5]."</td>";
echo "<td>".$row[6]."</td>";
echo "<td>".$row[7]."</td>";
echo "<td>".$row[9]."</td>";
echo "<td>".$row[8]."</td>";
echo "</tr>";
}
echo "</table></center>";
echo "</center>";
}
else {
// no
// print status message
echo "<center><FONT SIZE=18>";
echo $_GET["mnumber"];
echo " Materail is not found! </font>";
echo "</center>";
}
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
?>
<td><a href="/reviewtesting.php">Testing</a></td>
<?php
// include the page footer
include('footer.php');
?>
</body>
</html>