我意识到这可能是一个简单的执行问题,但我被困住了。我有记录 DELETE 就好了,但它没有显示在第二个表中。
<?php
if( $_SERVER['REQUEST_METHOD']=='GET' && isset( $_GET['job_numb'] ) ){
$job_numb = filter_input( INPUT_GET, 'job_numb', FILTER_SANITIZE_STRING );
}
?>
请注意上述网址中的服务器请求。这就是我通过$job_numb
的方式。现在,我将在下面的SELECT
查询中重新选择:
$servername = "localhost";
$username = "ccccc";
$password = "xxxxx";
$dbname = "jobs_users";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM jobs_canjobs WHERE job_numb = $job_numb";
$results = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_array($results)){
$job_name = $row['job_name'];
$comments = $row['comments'];
$due_date = $row['due_date'];
$show_date = $row['show_date'];
$attachment1 = $row['attachment1'];
$requestor = $row['requestor'];
$status = $row['status'];
$req_email = $row['req_email'];
$Property = $row['Property'];
$assignee = $row['assignee'];
$assign_email = $row['assign_email'];
$AE = $row['AE'];
}else{
echo 'no records found';
}
mysqli_close($conn);
?>
我还可以将这些结果放入一个数组中并从每个数据中选择,但在撰写本文时,这就是代码存在的方式所以我没有编辑该部分。
现在,所有这些变量都是从MySQL中加载的,与查询的$job_numb
相对应,您可以将它们添加到页面中以获得结果。
答案 0 :(得分:1)
尝试
$sql = "INSERT INTO `archived_jobs` SELECT * from `jobs_canjobs` where job_numb = $job_numb";
$results = mysqli_query($conn, $sql);
$sql = "DELETE FROM `jobs_canjobs` WHERE job_numb = $job_numb";
$results = mysqli_query($conn, $sql);