I have a for loop that writes the results of a query into a table. I have a variable ($rID_s
) that is being assigned from a value in the query. For some reason, it omits the first iteration. I have a variable for the total rows of the query and it is assigning the correct number. I've tried setting $i = 0
and $i = 1
and it still omits the first iteration of the array. If $i
is set to 0
, it adds a null
record to the table.
See below, the value for $rID_s is the variable that is not being assigned on the first iteration of the loop. Thanks in advance:
for ($i=1; $i <= $totalRows_rsClassReg; $i++) {
$row = mysql_fetch_array($rsClassReg);
$rID_s = $row['class_registry_student_ID_fk'];
mysql_select_db($database_SCOPE_test, $SCOPE_test);
$sql_aInstance = sprintf("INSERT INTO assignment_registry (assignment_reg_assignment_ID_fk, assignment_reg_student_ID_fk) VALUES (%s, %s)",
GetSQLValueString($aID, "int"),
GetSQLValueString($rID_s, "int"));
$Insert_aInstance = mysql_query($sql_aInstance, $SCOPE_test) or die(mysql_error());
echo $row['class_registry_student_ID_fk'] . " - ";
echo "Instanced";
echo "</br>";
}