I am currently working on an enrollment website for our research project. How to assign the section of a student where the course is "Computer Programming" limited to 50 per section? I currently have this but don't know what to do:
$course= $_POST[course];
$section= "Kindness";
$query2 = "SELECT * from students WHERE Specialization= 'Computer Programming'";
mysqli_query($conn,$query2);
$row = mysql_fetch_assoc($query2);
if($row['Specialization'] == $course){
$query3 = "INSERT INTO students (Section) VALUES ('$section')";
mysqli_query($conn,$query2);
}
}
You can do this in the same query... but i think you problem is other.. do you can change or insert new students? if you can insert you can do like this:
INSERT INTO students (Section)
SELECT
Section
FROM
students
WHERE
Specialization= 'Computer Programming'
/* here you can add other filters.. like rownum <= 50 (first 50 rows..)*/
But if you can change a value you can use a UPDATE..
I prefere resolve a problem in a one SQL query..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.