Page 1 of 1
Save into two database name
Posted: Wed Oct 03, 2018 6:33 pm
by yusa82
Hi
How can i save a form into two database in one form,
For example, i create a form with items name (the database table name is items) it contain name and stock, but the stock is readonly with numberformat
and i create a form with stock name (he database table name is stock) it lookup the items name and i can fill the stock there
The question is, how can i save the items database table name and stock database table name in the same time?
Re: Save into two database name
Posted: Thu Oct 04, 2018 12:30 am
by admin
yusa82,
How can i save a form into two database in one form,
Sorry but I don't understand.
Maybe you could show some screenshots.
Steven
Re: Save into two database name
Posted: Thu Oct 04, 2018 7:03 am
by yusa82
Thank you for the reply
Here is the screenshots
The items form only contain code item, item name and stock(readonly)
The stock form contain date, subform with lookup of the item and contain QTY to update the stock
how can i save and update the total QTY and stock from the different table name
Re: Save into two database name
Posted: Sun Oct 07, 2018 12:24 am
by admin
Re: Save into two database name
Posted: Mon Oct 08, 2018 6:13 am
by yusa82
wow ok thanks
here is my php code, it might useful if someone want to save into two database in one form
Code: Select all
$y = "update `tabel_b` inner join tabel_a ON tabel_a.tabelnameid = tabel_b.tabelnameid
set tabel_a.tabelname = tabel_b.tabelname";
$u = nuRunQuery($y);
Re: Save into two database name
Posted: Tue Oct 09, 2018 10:47 pm
by admin
.
Re: Save into two database name
Posted: Mon Oct 15, 2018 12:04 pm
by yusa82
ok now im facing new problem...
when i save using the query, the
table_a is saving from
table_b, but when i try to add another items with the same name, it won't save to the
table_a, it keep saving from the first data on
table_b, the second or third and more is not updating the
table_a
here is the code :
Code: Select all
$y = "update `items` inner join item_stock ON item_stock.items = items.items_id
set items.item_stock = item_stock.total";
$u = nuRunQuery($y);
The question is, what code should i put to get
items.item_stock = item_stock.total?
so that every time i save the form, it will update the items.item_stock.
Please help, im very new with this.
Re: Save into two database name
Posted: Tue Oct 16, 2018 11:23 pm
by admin
yusa82,
I would just update the 1 record that needs updating.
Code: Select all
nuRunQuery("UPDATE items SET item_stock = '#total#' WHERE items = '#RECORD_ID#' ");
Steven
Re: Save into two database name
Posted: Wed Oct 17, 2018 11:14 am
by yusa82
Steven,
it works like a charm...
Thank you
Re: Save into two database name
Posted: Wed Oct 17, 2018 11:52 pm
by admin
Cool.