我想記錄一個用戶輸入值,同時從另一個表中複製單個數據。可能嗎?多條插入語句
這裏是我的代碼:
$sql="INSERT INTO grades (studentnumber,subjectcode)
VALUES
('$_POST[studentnumber]','$_POST[subjectcode]')";
$sql="INSERT INTO grades (course) SELECT course FROM students WHERE studentnumber= '$_POST[studentnumber]'";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "<script type='text/javascript'>alert('Record Successfully Added'); location.href = '../instructor/cvsu-sis_students.php';</script>";
在此先感謝和抱歉,我的基本問題。
[SQL注入](HTTP ://en.wikipedia.org/wiki/Sql_injection)。瞭解它! – deceze 2012-02-15 09:36:16