I have a table named 'enroll' with the attributes:
student_id | section | enroll_num
| T4 | 1
| T6 | 2
| L2 | 3
enroll_num is the primary key and I have filled in the 'section' field with the code given below that uses values from another table. And it leaves the student_id empty. How would I fill in the NULL student_id field or is there a way to simulaneously fill in student_id as 'section' values are inserted?
if(isset($_POST['add2']))
{
$group = $_POST['group'];
$id = $_POST['id'];
$sql = "INSERT INTO enroll (section)
SELECT section FROM info3 WHERE group_no LIKE '%$group%'";
if (mysqli_query($conn, $sql))
{
echo "Successfully inserted";
}
else
{...
I have looked enough and have tried -
$sql2 = "UPDATE enroll SET student_id ='$id' WHERE student_id IS NULL";
but it is not working.