This topic is locked

[ASK} automatic sum from other table

10/6/2019 9:09:10 AM
PHPRunner General questions
B
belekok author

please help, i'm newbie

need automatic sum from other table


i'm use manual checkbox update selected

global $conn;

$sql="SELECT Sum(rincian.jumlah) Total FROM rincian WHERE rincian.idspt = ".$oldvalues['idspt'] . " AND rincian.idpelaksana = ".$oldvalues['id'];

$resql=db_query($sql,$conn);

$data=db_fetch_array($resql);

$values['jumlahrincian']= $data['Total'];


thanks

Sergey Kornilov admin 10/6/2019

Your code makes some sense but there is no image and it is not clear what is the question.

M
mersintarim 10/6/2019



please help, i'm newbie

need automatic sum from other table


i'm use manual checkbox update selected

global $conn;

$sql="SELECT Sum(rincian.jumlah) Total FROM rincian WHERE rincian.idspt = ".$oldvalues['idspt'] . " AND rincian.idpelaksana = ".$oldvalues['id'];

$resql=db_query($sql,$conn);

$data=db_fetch_array($resql);

$values['jumlahrincian']= $data['Total'];


thanks


$sql="SELECT Sum(rincian.jumlah) Total FROM rincian WHERE rincian.idspt = '".$oldvalues['idspt'] . "' AND rincian.idpelaksana = '".$oldvalues['id']."'";

B
belekok author 10/6/2019



Your code makes some sense but there is no image and it is not clear what is the question.



sorry upload prnt.sc

N
Nir Frumer 10/7/2019



sorry upload prnt.sc




hi, don't code this

use the "totals" option on the grid page
hope it helps,

C
Corrie 10/9/2019



hi, don't code this

use the "totals" option on the grid page
hope it helps,


The totals option on the grid page is a good idea.

The only condition is you won't have the total in the master table.
In case you still need to have the sum stored in the master table, try this:
global $conn;

$rs = db_query("SELECT Sum(rincian.jumlah) FROM rincian WHERE rincian.idspt = ".$oldvalues['idspt'] . " AND rincian.idpelaksana = ".$oldvalues['id']", $conn);

$data = db_fetch_numarray($rs);

$values['jumlahrincian'] = $data[0];
I hope this helps.

B
belekok author 10/9/2019



The totals option on the grid page is a good idea.

The only condition is you won't have the total in the master table.
In case you still need to have the sum stored in the master table, try this:
global $conn;

$rs = db_query("SELECT Sum(rincian.jumlah) FROM rincian WHERE rincian.idspt = ".$oldvalues['idspt'] . " AND rincian.idpelaksana = ".$oldvalues['id']", $conn);

$data = db_fetch_numarray($rs);

$values['jumlahrincian'] = $data[0];
I hope this helps.


code same with me, for manual check update selected


i'm need SUM in table pelaksana after record add in table rincian
thanks

F
fpilot 11/4/2019

Did it work out for you? i have same kind of problem. Pls advise



code same with me, for manual check update selected

i'm need SUM in table pelaksana after record add in table rincian
thanks