swapped to mysqli, added doc blocks to functions and added pagination methods