One method to do that is to set a SESSION variable during the routine/function that first updates the database.
PHP Code:
session_start();
if ($_SESSION['done_once']!="yes"){
//Put rest of routine/function here
$_SESSION['done_once']="yes";
}
//The above code will check to see if the $_SESSION['done_once'] variable
//has been set to "yes" and if not that means the database update has not
//been done so it will do it and then set the $_SESSION['done_once']
//variable. The $_SESSION variable is a super global and will remain set
//through the entire session or until changed by a script.