mysql function for setting interval via php