By: mpol_ch
Date: 2013-05-18
Time: 17:03
|
Reuse the SQL Value within tbs.php
Hello
I am using as below a SELECT and an INSERT INTO. I am ccalculating an SUM as Betrag in Mergeblock "bb". My Question is how can I take this value Sum(positionen.Total) AS Betrag over to use in my INSERT INTO statement as Betrag?
Thanks
mpol_ch
-------------
$TBS->MergeBlock('bb',$db,"SELECT vertraege.Id,
vertraege.Titel,
vertraege.Kunde,
vertraege.Strasse,
vertraege.Plz,
vertraege.Ort,
vertraege.Rechnungsadresse,
vertraege.Kontaktperson,
vertraege.Gueltigab,
vertraege.Gueltigbis,
vertraege.Fertigstellung,
Sum(positionen.Total) AS Betrag
FROM vertraege INNER JOIN
positionen ON vertraege.Id = positionen.Vertrag
WHERE vertraege.Id=$vnr
GROUP BY vertraege.Id");
$TBS->MergeBlock('pp',$db,"SELECT * FROM positionen Where Vertrag=$vnr ORDER BY sortindex");
//$TBS->MergeBlock('vdoc',$db,"INSERT INTO ver_docs (Gruppe ,KNr ,VNr ,Dokument ,Status) VALUES (12,12,12,12,12)");
$file_name = $datum.'_'.$kunde.'_'.$titel.'.doc';
// $TBS->PlugIn(OPENTBS_DEBUG_XML_SHOW);
$sql="INSERT INTO ver_docs values('','$gruppe','$knr','$vnr','$file_name','Betrag','1')";
mysql_query($sql);
|