added code to PHP file to auto calculate balance