Code snippets usage for Page Events April 18, 2020, 05:38:34 PM Hello,I have been trying to implement an automatic update on a field without success. I have a table “equipments” that has the fields: “code” and “type” (see bellow). The field “type” is always a combination of two letters, like “EP” or “PR”. I want to generate a sequential code field value after the user has entered the type. For that I need to get an array with all the code values for the type entered. I have been using the page events feature in PHPRad adding the code bellow to the equipments table in the AfterAdd session, but it doesn't seem to work. How to use the code snippets correctly for that? ThanksTable:equipments-----------------| code | type |-----------------| EP-001 | EP || PR-001 | PR || PR-002 | PR |Code:$params = array($rec_id);$codes = $db->rawQuery("SELECT code FROM equipments WHERE type = '" . $modeldata['type'] . "'", $params); Quote Selected
Re: Code snippets usage for Page Events Reply #1 – April 20, 2020, 02:15:34 PM this should be what you actually want to doCode: [Select]$params = array($modeldata['type'] );$codes = $db->rawQuery("SELECT code FROM equipments WHERE type = ?", $params); Quote Selected