This topic is locked

Editing a Table after ading a Record

6/27/2007 8:52:24 AM
PHPRunner General questions
C
coolkushi author

Hello Folks,
I was just building this application with PHP Runner...
Just wanted to know, once we add a record to one table, how can we edit some other table using the details entered..
let me make it clear..
suppose in we are having an inventory application...
i have two tables one is products and one is ledger....
once when i enter a record in ledger as follows..
Product: xxxx

Qty: 4

Type: credit/ debit
now after i enter this record in ledger table, it must automatically reduce/add the qty in the product table for the product xxxx

if credit is selected the product xxxx qty is reduce

and if debit is selected the product xxxx qty is increased...
hope to get some solution..

thanks in advance

Alexey admin 6/28/2007

Hi,
use Before record added event for this.

Here is the sample code:

--------------------------------------

global $conn;

$sql="update inventory set quantity=quantity";

if($values["Type"]=="credit")

$sql.="-".$values["Qty"];

else

$sql.="+".$values["Qty"];

$sql.=" where product='".$values["Product"]."'";