So I've been stuck on this do-while loop not working for about two hours. I really don't understand why it doesn't work. I'm getting this error:
Notice: Undefined offset: 9 in /public_html/me/yes.php on line 60
The only problem I think of is that it doesn't accept while loops in a do-while.
Here is my working code for just the inner while loop:
$maxcols = $numofcols-1; //=9
$maxrow = count($myarray)-1; //=44
$currentcol=0;
$currentrow=1;
//do {
$collection->insert(array($title[$currentcol] => $myarray[$currentrow][$currentcol]));
$currentcol++;
while ($currentcol<=$maxcols){
$newdata = array('$set' => array($title[$currentcol] => $myarray[$currentrow][$currentcol]));
$currentcol--;
$collection->update(array($title[$currentcol] => $myarray[$currentrow][$currentcol]), $newdata);
$currentcol++;
$currentcol++;
}
$currentrow++;
//} while ($currentrow<=$maxrow);
If I uncomment the two line's "//do {" and "//} while ($currentrow<=$maxrow);" my program dies with the error I mentioned above. Is there something dead simple as to why it's breaking my code? Thanks in advance
UPDATE:
Line 60 is:
$collection->insert(array($title[$currentcol] => $myarray[$currentrow][$currentcol]));