$test2 = next($d['fld_nav_index']); // value in the NEXT row
The next() function moves the internal array pointer of the passed array and returns the next element. $d['fld_nav_index'] is not an array. This should trigger a PHP E_WARNING?
Rather than trying to look ahead to the next row, I think it might be easier to remember the previous row and look back - so you always have two entire rows in memory. Assuming you need to examine every row and not every other row.