How can I pass my query values from mysqli_fetch_array?
<p>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.</p>

<pre><code>$query  = "SELECT cnum, cname FROM course WHERE specialization = '0'";  
 $result = mysqli_query($conn,$query);

 if (!$result) die ("Database access failed: " . $conn-&gt;error);

 $rows = $result-&gt;num_rows;    
for ($j =0; $j&lt;$rows;++$j) {

     $row = mysqli_fetch_array($result);
     $query = "INSERT INTO student_schedule VALUES ('$studentID', '$row[0]', '$row[1]', '0')";

     $result = $conn-&gt;query($query);
     if (!$result) die ("Database access failed: " . $conn-&gt;error);

 }
</code></pre>