Printing SQL query results into an array