Php code that handle creating and updating table values