Hello,
I'm writting a function for one of my classes at the moment, but have come across a problem.
I have a nested while loop, that looks like this:
while (!$exclusionHarmonics->EOF)
{
// Set the variables.
$id = $exclusionHarmonics->fields[0];
$A_or_B = $exclusionHarmonics->fields[1];
$DegreeN = $exclusionHarmonics->fields[2];
$OrderM = $exclusionHarmonics->fields[3];
// Loop through the returned record set($exclusionList).
while (!$exclusionList->EOF)
{
$monitorSet = $exclusionList->fields[0];
$harmonic = $exclusionList->fields[1];
if ($harmonic = $id)
{
$checkbox[$i] = '<input type="checkbox" name="checkbox_'.$i.'" value="ID" checked>';
}else{
$checkbox[$i] = '<input type="checkbox" name="checkbox_'.$i.'" value="ID">';
}
echo ('Iteration '.$i.' = '.$checkbox[$i].'<br> MonitorSet = '.$monitorSet.'<br> Harmonic = '.$harmonic);
$i++;
$exclusionList->MoveNext();
}
echo ('<br><br>ID = '.$id);
$exclusionHarmonics->MoveNext();
// Create the HTML code for the table rows and cells.
for ($j = 0; $j<=($i-1); $j++)
{
$html .= '<tr align="center"><td>'.$id.'</td><td>'.$A_or_B.
'</td><td>'.$DegreeN.'</td><td>'.$OrderM.
'</td><td>'.$checkbox[$j];
}
}
This is the first time i've used ADODB, and its been great up until now. I have spent the last 3 hours trying to figure out why it doesn't work, and i think i know why.....i just don't know how to get round it.
I believe the problem is due to 2nd loop (while (!$exclusionList->EOF)). The very last statement in this loop is $exclusionList->MoveNext();, this is the equivelant of $i++, if $i was the loop iterator (or next $i - if you like Visual Basic). The problem is, that once it has been through the loop once, it remains on the last element of the loop, so when it tries to go through the loop again, it cant cause its already at the end.
I'm sure i've read something in the adodb documentation about how to overcome this, but i can't seem to find it anymore. I think it was some sort of reset function, but like i say, im not sure.
I'm sure everyone who's ever used adodb must have come across this problem at some point, so i'm hoping that someone will be able to help me.
Cheers