Morning,
We have a script for spliting the data we get from a mysql database (based on this answer: https://stackoverflow.com/a/8660624/1067100) in a table with three columns, in the case of the current example, we have a database that returns 8 values but appear 9 (latter completely empty).
The current image can clarify the problem if it has become abundantly clear, and also a link to the code we think is wrong. We have reviewed but we are not able to find out what the problem.. :/
the code: https://gist.github.com/99df1288cd1d998c8172

Thanks in advance.
The queickest fix is that you need a “break” in the inner loop.
Note that you should save a fractional bit of computing power by storing count($data) in a variable – unless you expect the count to change.