正如标题所示,我想将mysql中唯一引用的记录从一个表移动到另一个表。
我自己尝试了很多不同的方法以及其他成员的建议。
我会告诉你我的两页我想要上班的东西。一个是第一个表中的记录表。在每一行上都有一个链接,用于将行的数据从该表复制到另一个表。我只是不能让代码在第二页上工作,将数据复制到另一个表。
P.S。完成之后我将完成所有代码以尝试查找sql注入。
请有人试着帮我解决这个问题,因为它让我发疯了。
感谢您的提前时间。
Table.php
<?php
require_once('auth.php');
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="Instruction"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM Instruction";
$result=mysql_query($sql);
?>
<style type="text/css">
body {
background-color: #FFF;
}
</style>
<p> </p>
<p> </p>
<p> </p>
<table width="1400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="1400"><table width="1270" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="400"><p align="center"><strong>List of Instructions</strong></p></td>
</tr>
<tr>
<td width="70" align="center"><strong>Reference</strong></td>
<td width="120" align="center"><strong>Forename</strong></td>
<td width="120" align="center"><strong>Surname</strong></td>
<td width="100" align="center"><strong>DOB</strong></td>
<td width="120" align="center"><strong>Mobile Number</strong></td>
<td width="120" align="center"><strong>Home Number</strong></td>
<td width="120" align="center"><strong>Address</strong></td>
<td width="100" align="center"><strong>Postcode</strong></td>
<td width="100" align="center"><strong>Email</strong></td>
<td width="100" align="center"><strong>Accident Date</strong></td>
<td width="120" align="center"><strong>Accident details</strong></td>
<td width="120" align="center"><strong>Refer for Triage</strong></td>
<td width="120" align="center"><strong>Refer for IA</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['Reference']; ?></td>
<td><? echo $rows['Forename']; ?></td>
<td><? echo $rows['surname']; ?></td>
<td><? echo $rows['DOB']; ?></td>
<td><? echo $rows['Mobile']; ?></td>
<td><? echo $rows['Home']; ?></td>
<td><? echo $rows['Address ']; ?></td>
<td><? echo $rows['Postcode1']; ?></td>
<td><? echo $rows['Email']; ?></td>
<td><? echo $rows['Accident']; ?></td>
<td><? echo $rows['Details']; ?></td>
<td align="center"><a href="refertotriage.php?Reference=<? echo $rows['Reference']; ?>">Refer for Triage</a></td>
<td align="center"><a href="update.php?Reference=<? echo $rows['Reference']; ?>">Refer for IA</a></td>
</tr>
<?php
}
?>
</table></td>
</tr>
</table>
<p>
<?php
mysql_close();
?>
</p>
<p> </p>
逻辑/ code.php
<?php
require_once('auth.php');
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="Instruction"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//$Reference=$_REQUEST['Reference'];
//$Forename=$_REQUEST['Forename'];
//$surname=$_REQUEST['surname'];
//$DOB=$_REQUEST['DOB'];
//$Mobile=$_REQUEST['Mobile'];
//$Home=$_REQUEST['Home'];
//$Address=$_REQUEST['Address'];
//$Postcode=$_REQUEST['Postcode1'];
//$Email=$_REQUEST['Email'];
//$Accident=$_REQUEST['Accident'];
//$Details=$_REQUEST['Details'];
//semi colon removed
// $sql="INSERT INTO
// Triage
// (
// Reference,
// Forename,
// surname,
// `D.O.B`,
// `Mobile Number`,
// `Home Number`,
// Address,
// Postcode1,
// Email,
// Accident,
// Details
// )
// VALUES
// (
// '".$Reference."',
// '".$Forename."',
// '".$surname."',
// '".$DOB."',
// '".$Mobile."',
// '".$Home."',
// '".$Address."',
// '".$Postcode1."',
// '".$Email."',
// '".$Accident."',
// '".$Details."'
// )";
// $result=mysql_query($sql);
//$sql="INSERT INTO Triage (Reference, Forename)
//SELECT Reference, Forename from `Instruction` WHERE Reference='$Reference'"
$Reference=mysql_real_escape_string($_GET['Reference']);
$sql="INSERT INTO Triage (Reference, Forename)
SELECT Reference, Forename FROM `Instruction`
WHERE Reference='$Reference' LIMIT 1";
// echo "Successful";
// echo "<BR>";
// echo "<a href='list_records.php'>View result</a>";
// mysql_error()
echo $sql;
?>
答案 0 :(得分:0)
我自己已经解决了这个问题。我没有'获得参考,所以他们不知道需要移动什么记录。