CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [RESOLVED] CCDLookup help

Print topic Send  topic

Author Message
Dorin

Posts: 50
Posted: 10/25/2010, 11:12 PM

Hello,

I have a mysql table (amounts), that looks like:

date | amount | type
-------------------------------
date1 | x | 1
date2 | y | 2
date3 | z | 1
.....

In a page, that could have or not a url parameter for date (data_s), I want to have a label that will show a total calculated like this:

if (!CCGetFromGet("data_s","")) then {
global $DBConnection1;
$Page = CCGetParentPage($sender);
$ccs_result = CCDLookUp("sum(amount)", "amounts", "type=1" and "date <=CURDATE()") - CCDLookUp("sum(amount)", "amounts", "type=2" and "date <=CURDATE()")
$Page->Connections["DBConnection1"]);
$Container->Label1->SetValue($ccs_result);

}
else
{

global $DBConnection1;
$Page = CCGetParentPage($sender);
$ccs_result = CCDLookUp("sum(amount)", "amounts", "type=1" and "date <=CCGetFromGet("data_s","")") - CCDLookUp("sum(amount)", "amounts", "type=2" and "date <=CCGetFromGet("data_s","")")
$Page->Connections["DBConnection1"]);
$Container->Label1->SetValue($ccs_result);
}

But my code it's a mess. Could anyone help me?
Many thanks


View profile  Send private message
Dorin

Posts: 50
Posted: 10/26/2010, 5:36 AM

ok, I found some mistakes so the code now looks like:

$global $DBConnection1;
$Page = CCGetParentPage($sender);
if (CCGetParam("data_","")=="") {
$ccs_result = CCDLookUp("sum(amount)", "amounts", "iTip=1 and data<=CURDATE()", $Page->Connections["Connection1"]) - CCDLookUp("sum(amount)", "amounts", "iTip=2 and data<=CURDATE()", $Page->Connections["Connection1"]);
}
else {
$ccs_result = CCDLookUp("sum(amount)", "amounts", "iTip=1 and data<=".CCGetParam("data_s",""), $Page->Connections["Connection1"]) - CCDLookUp("sum(suma)", "registru", "iTip=2 and data<=".CCGetParam("data_s",""), $Page->Connections["Connection1"]);
}
$Container->Label1->SetValue($ccs_result);

The code works only when there is no url parameter (data_s). If I have the data_s parameter, the result is invariable 0.

:(
View profile  Send private message
Dorin

Posts: 50
Posted: 10/27/2010, 2:06 AM

after some of my nails got eaten, i figure out:

global $DBConnection1;
$Page = CCGetParentPage($sender);
if (CCGetParam("data_s","")=="") {
$ccs_result = CCDLookUp("sum(amount)", "amounts", "iTip=1 and data <= CURDATE()", $Page->Connections["Connection1"]) - CCDLookUp("sum(amount)", "amounts", "iTip=2 and data <= CURDATE()", $Page->Connections["Connection1"]);
}
else {
$datax=CCGetParam("data_s","");
$ccs_result = CCDLookUp("sum(amount)", "amounts", "iTip=1 and data <='".$datax."'", $Page->Connections["Connection1"]) - CCDLookUp("sum(amount)", "amounts", "iTip=2 and data <='".$datax."'", $Page->Connections["Connection1"]);
}
$Container->Label1->SetValue($ccs_result);
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.