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]));
$title[9], which as you just said does NOT exist... What about trying to see what's wrong with your currentCol variable.... Maybe just add a checkif ($currentCol<9) {then and only then, do... what's following...foreach? This seems a C++ way of handling arrays. Take a look at that.