我正在做一个项目,该项目具有用户批准或撤销申请的能力(例如奖学金)。但我似乎无法找出为什么它没有做我想做的事。请检查我下面的代码:
$try = mysql_query("UPDATE new_applicants SET ApplicantStatusId='$status', DateManaged = NOW() WHERE ApplicantId='$id'") or die(mysql_error());
$try1 = mysql_fetch_assoc($try);
$status1 = $try1["ApplicantStatusId"];
if( $status1 == 2 ){
header('location: ../employeepage.php');
exit();
}
else{
$sql1 = "INSERT INTO scholar_profile (Firstname, Middlename, Lastname, Address, EmailAddress, BirthDate, BirthPlace, Religion, Age, Gender, ContactNo, Skill, Talent, LevelId, GWA, CategoryId, StatusId, SchoolId, BarangayId) SELECT Firstname, Middlename, Lastname, Address, EmailAddress, BirthDate, BirthPlace, Religion, Age, Gender, ContactNo, Skill, Talent, LevelId, GWA, CategoryId, StatusId, SchoolId, BarangayId
FROM new_applicants
WHERE new_applicants.ApplicantId = '$id'" or die(mysql_error());
}
当applicantstatus变为2=撤销时,不应将数据复制到scholar_profile。但当我尝试这个时,它仍然复制。这有什么问题吗?谢谢。
最佳答案
您正在更新表,因此mysql_fetch_assoc
不会返回任何内容。 IE。 $status1
将为 null
。如果您想选择该数据(ApplicantStatusID,...),则必须使用 SELECT
语句。
关于php - mysql/php sql 语句逻辑错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14165682/