This topic is locked

beforeadd

7/11/2006 8:43:08 AM
PHPRunner General questions
J
jim9 author

If field1 is an autonumber and primary key, and I need to capture it into a variable in beforeadd event ie., $_SESSION["field1"] = $values["field1"]; , How can I achieve this.

Bear in mind, I probably will want this field as a read only or hidden field, thus it's not in values array. In the before and after edit I capture it by passing $key to the function. However, since it doesn't exist yet on an add page, I get errors no mater how I try to get it. How can I get this new generated autonumber into a variable so I can use it in a after add event? I have no problem with this in a after edit event.

J
Jane 7/11/2006

Jim,
auto-increment field is filled after record was added. Therefore there is no value of auto-increment field in the $values array.

I recommend you to use following code for the After record added event:

function AfterAdd()

{

global $conn;

$_SESSION["CountryID"] = mysql_insert_id($conn);
}