document write and sql array working