This sounds alot more like a database problem..Your code looks good to me. Have you tried running the $query it output by hand? does it return a result? If it doesn't, you will want to add a statement like
if($arrayObject = mysql_fetch_array($result))
to alert your program for handling code for empty sets.
If it does, I don't know. the ONLY part of your code that's different from the way I do it is
echo $row[$i];
I usually use a foreach loop and do:
foreach($row as $key => $value)
echo $row[$key];
but that shouldn't chantge anything