replace mysql with queryDB(), and fix pagination