Mysql无法保存一些记录 [英] Mysql fails to save some records

查看:85
本文介绍了Mysql无法保存一些记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用PHP开发的多用户应用程序来管理学生记录。该应用程序使用foreach循环来更新每个学生记录。在大多数情况下,应用程序工作正常,但有几次用户报告他们的记录尚未保存可能是这个问题的原因?



我尝试了什么:



I have a multi-user application developed in PHP to manage student records. The application uses a foreach loop to update each student record. In most instances, the application works just fine but there are a few times when users report that their records have not been saved What could be the cause of this problem?

What I have tried:

<pre>foreach($ExamMarks as $Key=> $Value)
				{
				

				$Student = array(explode(" ",$Value)); //This will convert the Values into a multi-dimensional array and store the new values in $Student

						
								
							if(trim($_POST[$Student[0][1]]) == "Null" || trim($_POST[$Student[0][1]]) == " ")//If the student has a mark
							{

										$Grade = "";
										$Comments = "";
										$Points = "";

							}
							
										else if(trim($_POST[$Student[0][1]]) >= 80)
										{

												$Grade = "A";
												$Comments = "Outstanding performance. Keep it up!";
												$Points = 9;

										}
										else if (trim($_POST[$Student[0][1]]) >= 70)
										{


										   $Grade = "B";
										   $Comments = "Good performance. Aim higher.";
										   $Points = 7;

										 }

										else if (trim($_POST[$Student[0][1]]) >= 60)
										{


											$Grade = "C";
											$Comments = "Fairly good performance. Work hard.";
											$Points = 5;

										}
										else if (trim($_POST[$Student[0][1]]) >= 40)
										{


											$Grade = "D";
											$Comments = "Average performance. Work harder.";
											$Points = 3;

										}
										else if (trim($_POST[$Student[0][1]]) >= 20)
										{

											$Grade = "E";
											$Comments = "Below Average. Put more effort.";
											$Points = 1;

										 }
										 else
										{


											$Grade = "U";
											$Comments = "Ungraded";
											$Points = 0;

										}

$updateSQL = "UPDATE student_exam_marks_exam SET
											   ExamMark = " 		. preg_replace('#[^0-9]#i', '',trim($_POST[$Student[0][1]])) . ",
											   ExamGrade = '" 		. $Grade . "',
											   Comments = '" 		. $Comments . "',
											   Points = " 			. $Points . " ,
											   TeacherID = '" 		. $row_Select_Teacher["TeacherID"] . "'
											   WHERE ExamID = " 	. $ExamID . " AND StudentID = " . trim($Student[0][0]) . "
											   AND SubjectID = " . $_GET["SubjectID"] . " AND AcademicYear = " . $row_Select_Exams["AcademicYear"].";" ;
									   
	
							      mysqli_select_db($con, $database);
								  $Result1 = mysqli_query($con,$updateSQL) or die(mysql_error($con));
}

推荐答案

ExamMarks as
ExamMarks as


Key =>
Key=>


Value)
{
Value) {


这篇关于Mysql无法保存一些记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆