I am trying to insert values into a table in my database. The first param is a non null variable, the next two are the two columns I want to pass in as well. What is wrong with my logic here.
$query = "SELECT cnum, cname FROM course WHERE specialization = '0'";
$result = mysqli_query($conn,$query);
if (!$result) die ("Database access failed: " . $conn->error);
$rows = $result->num_rows;
for ($j =0; $j<$rows;++$j) {
$row = mysqli_fetch_array($result);
$query = "INSERT INTO student_schedule VALUES ('$studentID', '$row[0]', '$row[1]', '0')";
$result = $conn->query($query);
if (!$result) die ("Database access failed: " . $conn->error);
}