-1

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);
        }

}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Brenz
  • 67
  • 1
  • 7

1 Answers1

0

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..

  • Thank you so much! I changed it to UPDATE. Thank you for your help I really appreciate this. – Brenz Nov 19 '19 at 23:26