Beh, facci anche vedere come la generi la variabile $righe, che a quanto pare è un array.