簡體   English   中英

從 1 個表中獲取行並將其插入到另一個表中

[英]Fetching rows from 1 table and inserting it into another

我必須從表 workplan_progress 中獲取所有行並將其插入另一個表 exco。 我已經使用了這段代碼,但沒有結果。 exco 表中看不到任何數據。 我也嘗試了很多其他方法,但始終沒有得到任何答案。

include("includes/connect.php");
$id=$_GET['id'];
$sql="SELECT * FROM workplan_progress where id='$id'";
$query=mysql_query($sql);
$row=mysql_fetch_array($query, MYSQL_ASSOC);

$value1 = $row['division_name'];
$value2 = $row['division_chief'];
$value3 = $row['period'];
$value4 = $row['month'];
$value5 = $row['activity_name'];
$value6 = $row['unit'];
$value7 = $row['weightage'];
$value8 = $row['per_100'];
$value9 = $row['per_75'];
$value10 = $row['per_50'];
$value11 = $row['per_<50'];
$value12 = $row['measurement'];
$value13 = $row['score'];
$value14 = $row['progress'];
$value15 = $row['indicator_measure'];

$sql1 = "INSERT INTO 'exco' SET                 division_name='$value1',
                                                division_chief='$value2',
                                                period='$value3',
                                                month='$value4',
                                                activity_name='$value5',
                                                unit='$value6',
                                                weightage='$value7',
                                                per_100='$value8',
                                                per_75='$value9',
                                                per_50='$value10',
                                                perless50='$value11'
                                                measurement='$value12'
                                                score='$value13'
                                                progress='$value14'
                                                indicator_measure='$value15'
                                                ";

$query1 = mysql_query($sql1);
if(isset($query1)){
        $_SESSION['msg']='This work progress has been forwarded to exco for approval.';
    }
    echo "<script>window.location='admin_workprogress.php?msg=success'</script>";

?>

您在此處的表名稱周圍有單引號:

$sql1 = "INSERT INTO 'exco' SET

你需要的是沒有單引號的這個:

$sql1 = "INSERT INTO exco SET

或者更好,這帶有反引號:

$sql1 = "INSERT INTO `exco` SET

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM