You are using an array to store all your data records, but only a single variable to store the odd/even. $bg will be overwritten every time a record is retrieved, and will always be set to whatever the last record was.
You need to move the $bg out of this loop, and into the loop you use for displaying the content:
Yeah, you can now remove the alternating color variable from the data set because in reality it explicitly belongs within the template layer. The =! assigns the inverse value to $cycle each iteration. The inverse of true is false and false is true so what you get is an alternating two dimensional pattern. Coupled with the ternary operator every time $cycle resolves to false odd class is applied the ul and no class is applied when its true.
Oh… and the actually code is the below because the previous code assigns odd to even columns. Either way though your differentiating the rows.
Just a matter of personal preference really, however you could argue computerbarrys is slightly better as it only uses a single CSS class, rather than two. Although in some cases it might be handy to have two seperate classes for the alternating rows.
There’s always more than one way to skin a cat, choose whichever works best for you.