I was recently working on a web page that sorted data that came back from a database in an array. I managed to get the page working and then realized after testing, that it was returning some rows that were messing up my table structure. After searching the data I came across some missing or Null data on one particular column. The data was being pulled in from a view in the database. The reason I was getting null data from that column was due to how the view was filtering the data. So after thinking the code on the page was at fault for most of the day, it turned out that I was using a restrictive view on the data.
Lesson learned – if your code seems to be working, go check your database for other possible reasons it may be breaking. If I had done that sooner, I would have found the issue a lot faster.