|
|
In CodeCharge Studio you can access the WHERE clause associated with a Grid and utilize it to lookup the record count or field total. To utilize this feature, place a label anywhere on the page, then place the following code in the label's "Before Show" event:
ASP: if <form_name>.DataSource.Where = "" then [<form_name>.]<label_name>.Value = CCDlookUp("count(*)", "<table_name>", "0=0", DB<connection_name>) else [<form_name>].<label_name>.Value = CCDlookUp("count(*)", "<table_name>", <form_name>.DataSource.Where, DB<connection_name>) end if
PHP: global $<form_name>; global $DB<connection_name>; if ($<form_name>->ds->Where == "") [$<form_name>->]<label_name>->SetValue(CCDLookUp("count(*)", "<table_name>", "0=0", $DB<connection_name>)); else [$<form_name>->]<label_name>->SetValue(CCDLookUp("count(*)", "<table_name>", $<form_name>->ds->Where, $DB<connection_name>));
Replace the values between < > with the appropriate form, lable, table and database connection names. The square brackets around the form name [<form_name>] indicate that this parameter is optional, for example if the label is placed outside of the form. Instead of the COUNT function, you can also use SUM and other SQL functions. |
Viewed
20898 times. Last updated: 11/11/2002 4:32:31 PM
|
|