嘿傢伙即時嘗試更新我的數據庫使用php ang ajax,但假設文本框是動態多數民衆贊成爲什麼即時嘗試更新數據庫使用多個更新只需點擊一下按鈕,但我的火蟲「您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以在'='100'附近使用正確的語法WHERE student_id ='33'AND subject_id ='2'AND school_id =' 1'和第1行的adv'我不太確定我的代碼,因爲我只是試驗如何在php中使用ajax。多個更新使用ajax與PHP
PHP:
session_start();
$school_id = $_SESSION['school_id'];
$faculty_id = $_SESSION['user_id_fac'];
$subject_id = $_POST['subject_id'];
$year_grade_level = $_POST['year_level'];
$subject_handeler_id = $_POST['subject_handler_id'];
$student_grades_boy = $_POST['student_grades_boy'];
$student_grades_girl = $_POST['student_grades_girl'];
$update_grades_boys = "UPDATE registrar_grade_archive SET";
//SET status = '0' WHERE subject_id = '$subject_id'"
$vaues_girl = array();
$values_boy = array();
foreach ($student_grades_boy as $key=>$data) {
$student_id_B= $data['studnt_B_id'];
$grade_B = $data['studnt_grade_B'];
$values_boy[$key] = 'grade = \''.$grade_B.'\' WHERE student_id = \''.$student_id_B.'\' AND subject_id = \''.$subject_id.'\' AND school_id = \''.$school_id.'\' AND advisor_faculty_id = \''.$faculty_id.'\' AND subject_handler_id = \''.$subject_handeler_id.'\' ' ;
}
$values_boy = implode(', ', $values_boy);
$ready_edit_grades_boy = $update_grades_boys . $values_boy;
$save_grades_boy = mysql_query($ready_edit_grades_boy) or die(mysql_error());
請幫助球員。在此先感謝
是你所有的ID字符串嗎?你正在用單引號包裝。整數不需要引號。事實上,你所有的數字都用引號括起來。 – Leeish
[**請不要在新代碼中使用'mysql_ *'函數**](http://bit.ly/phpmsql)。他們不再被維護[並被正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。如果你選擇PDO,[這裏是一個很好的教程](http://j.mp/PoWehJ)。 – Kermit
迴應此查詢$ ready_edit_grades_boy並將輸出粘貼到此處,以便我們可以看到 –