CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 How to query for total records?

Print topic Send  topic

Author Message
Wizywyg
Posted: 01/23/2003, 6:38 PM



How do you get CCS to query for total amt of records in a table?
Ie, I have 20 items listed in the DB. How would you get CCS to construct a query to look at a certain table, count how many items and return total number in that table?
RonB
Posted: 01/24/2003, 7:21 AM

Use sql. ie select count(*) from yourtable

If you want to show this numer you could insert an extra label in your grid, set it to code expression and do a beforeshow event on that label(php)=>

global $yourgrid;
global $DByourconnection;

$yourgrid->labelname->setvalue(CCDLookup("select count(*) from yourtable",$DByourconnection));

RonB

Wizywyg
Posted: 01/24/2003, 11:41 AM

How do you construct it using the Visual Query thing?
WizyWyg
Posted: 01/24/2003, 11:48 AM



Okay, I have no idea what you just posted.
First I have to construct something? What is a grid?
How do you label something?

What does the grid do? How do you use the grid? Is that Visual Query tied to it? I haven't been able to figure out to use that Visual Query thing...Not much is explained in the help file.
RonB
Posted: 01/25/2003, 6:53 AM

"Okay, I have no idea what you just posted.
First I have to construct something? What is a grid?
How do you label something?"

the tutorial and manual will give you an answer to the above questions. They are very basic questions and even though I agree documentation is poor that's on a more advanced level. The basics, like your questions, are well covered.

I can't help you if you do not grasp these basic idea's behind not only codecharge but all tools like it. If you do not know that a grid is for displaying data from the database I can't even begin to explain what events are. The code I gave you is what you would use in a beforeshow event. You'll want to know before showing what?

read the manual, do the tutorial and read my posting, ask again if you still are having trouble with it. I'll be glad to help.

Ron
wizywyg
Posted: 01/27/2003, 12:28 AM

"the tutorial and manual will give you an answer to the above questions. They are very basic questions and even though I agree documentation is poor that's on a more advanced level. The basics, like your questions, are well covered."


What tutorial? The Employee task tutorial? It doesn't cover PHP, but ASP which im not working in. The codign is different. Also hte manual doesn't explain how to get total records.



"I can't help you if you do not grasp these basic idea's behind not only codecharge but all tools like it. If you do not know that a grid is for displaying data from the database I can't even begin to explain what events are."


Then explain using terms that are found in PHP. Like Tables and table data, and how they are retrieved using a "grid" or "record". In php, there is no such thing as using a "grid" to pull "data" from a database.


Someone should write the manual for all programming languages that its supposed to be for and offer examples for each language. And a tutorial that address all languages. Tutorial starts off as generic, but then goes into ASP specific language.
RonB
Posted: 01/28/2003, 2:15 AM

http://support.codecharge.com/tutorials.asp

please...
it wasn't that hard to find :-)
Ron
Peter
Posted: 01/30/2003, 12:24 AM

It goes like this:

... database GRID = spreadsheet TABLE
... count(*) is SQL for total record count

BTW, the above has nothing to do with php/asp/etc. it's just very basic understanding of database structure and SQL (= the language of most databases)
Wizywyg
Posted: 01/30/2003, 11:13 AM

http://support.codecharge.com/tutorials.asp

Yeah, that tutorial only does an Employee TASK and its targeted for ASP programmers (of which Im not using); do they have that tutorial for PHP (or all in PHP)?

Michael Mikkelsen
Posted: 01/30/2003, 2:51 PM

This is a very good question and I figured out the answer.

CCS does this for you automatically and here is how you access the variable.

Create a Grid for the table that you want to get the count of. If you don't want to show the data in that Grid simple delete everything between the Grid tags. They look something like this [[]> <[]]. Now add a label to the Grid using Toolbox - Form - Label. The new Label will be called Label1.

Add this code to the BeforeShow event for Label1:

global $grid_name1;
$num = $grid_name1->ds->RecordsCount;
$grid_name1->Label1->SetValue( $num );

In this example the name of the grid was grid_name1 and the name of the label you added to it was Label1.

There you go,

Michael Mikkelsen
Wizywyg
Posted: 01/30/2003, 4:17 PM

Thanks Michael Mikkelsen it works, though you forgot to run a query on the grid to get information from what Data Source.
GreggB
Posted: 01/31/2003, 9:28 AM

Hey Michael,

I don't do much in PHP or any other language for that matter, but give this a try in your Grid rather than using an Event.


1. In the Grid, select the Label Properties which will display the record count. Under the Data Tab set the following:
a. Control Type = Code Expression
b. Control Source = $This->ds->RecordsCount
c. Data Type = Integer

That's it, let me know if it works?

GreggB









Wizywyg
Posted: 01/31/2003, 12:17 PM

GreggB,


just tried your code, and I get a blank value.
GreggB
Posted: 02/01/2003, 5:52 AM

Humm...


With the exception that the "T" in $This should have been $t and there is a query in the in the Grid it should display the total record count. Below are the two solutions I use and they both work for me. I think I have covered enough of the steps that you should be able to get them to work.

1. Add a Grid to your page from Forms with the following Properties:

[Grid Properties Data Tab]
a. Name: NewGrid1
b. Connection: YourConnection
c. Source Type: Table
d. Data Source: YourTable

I deleted Label2 moved Label1 to the Grid's Title as; Total {Lable1}

2.Configure Lable1 Properties Data tab as below:
a. Control Type: Code Expression
b. Control Source: $this->ds->RecordsCount (for PHP)
b. Control Source: Recordset.RecourdCount (for ASP)
c. Data Type: Integer

Run a Live test and the result should be displayed on the page as;

Total 125 (your total number of records in your table)

--------------------------------------------
Another solution:

1. Add a Grid to your page from Forms with the following Properites:

[Grid Properties Data Tab]
a. Name: NewGrid1
b. Connection: YourConnection
c. Source Type: SQL
d. Data Source: Select Count(YourColumn) AS label1 From YourTable
(You can click on the 3 dots “…” to open up the query builder if you like)

Delete Label2 and move Label1 to the Grid's Title as Total {Lable1}

2. Configure Lable1 Properties Data tab as below:
a. Control Type: Database Column
b. Control Source: label1
c. Data Type: Integer

I did a Live test and the result (total records) is displayed the page as;

Total: 125 (your total number of records in your table)


GreggB



   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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