CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 Incrementing a field

Print topic Send  topic

Author Message
Ken
Posted: 08/07/2002, 6:50 PM

A little while ago I saw an article or discussion on this site about incrementing a field that would show the amount of times a record has be accessed. Sort of like a hit counter for a record. Can anyone point me to where this is or tell me how to do it?

I am using PHP 4, CCS 1.0.6

Thanks!
Nicole
Posted: 08/08/2002, 5:28 AM

Ken,
please search on "hit count" keyword on this forum. There were several postings on this issue. The approach is the same for CC and CCS
Ken
Posted: 08/08/2002, 5:50 PM

How do you make this work in a Before Show event in CCS using PHP 4.0?

I have a database table called codes, field called Hits, and the Parameter I am passing is called RecNo.

I have tried this code:

if (get_param("RecNo") != "")
$db->query("update codes set Hits = Hits+1 where RecNo=" . get_param("RecNo"));

I get an error stating the get_param function is not defined.


Nicole
Posted: 08/09/2002, 5:28 AM

Ken,
The code for PHP+CCS is:
1. Using existent connection
global $DBconnection_name;
if (GetParam("RecNo", "") != "")
$DBconnection_name ->query("update codes set Hits = Hits+1 where RecNo=" . GetParam("RecNo", ""));

2. or open new connection:
$conn = new clsDBconnection_name();
if (GetParam("RecNo", "") != "")
$conn->query("update codes set Hits = Hits+1 where RecNo=" . GetParam("RecNo", ""));
Ken
Posted: 08/09/2002, 8:10 AM

Thanks Nicole, I will try this later tonight. In a topic from 7/17/02 (below) you gave someone advice on how to place the record count on the end of a topic. Consider this: I have a page listing just the topics. The Topic field is a link to a listing page. I want the Topic follwed by the number of records corresponding to the topic listed from another table called codes. I also want the link from the topic field to send a query to the listing page to list just the selected topic. My table name for the topics table is topics, the field name is topiccat and a label defined as count. The page I am linking to is called code_list, the table is codes, with fields RecNo(primary), topic. How can I do this in CCS and PHP 4.0? Thanks in advance!

Previous similar topic:

Topic add number after links: ex dentists(22) in CCS

Author Nicole
Date Created 7/17/02 6:13:13 AM
Message Mickael,
I think you need some manual coding to solve it. Create Before Show Row event. There you should look up the number of records for each category, then concatenate it with field value. E.g.:
PHP
global $form_name;
global $DBconnection_name;
$number = CCDlookUp("count(*)", "table_name", "foreign_key_field=" . $form_name->promery_key_field->Value, $DBconnection_name);
$form_name->category_name->SetValue($form_name->category_name->Value. " (". $number. ")");
Ken
Posted: 08/09/2002, 8:36 PM

Neither of you suggestions work. With the one that tries to instaniate a new class, it says it can't on a non-existent class and the other one also gives me a fatal error that the object does not exist. I also noticed that the GetParam method is CCGetParam in CCS. I know we are close, what could be wrong? Thanks in advance!
Nicole
Posted: 08/10/2002, 4:08 AM

Ken,
have you placed the code on the includable page or normal one?
Ken
Posted: 08/10/2002, 8:07 PM

Instead of asking me where I put the code, why don't you tell me where it is supposed to be? I have the code in a page called view, in the before show event. This is the page that displays the hit counter. What is an includable page? What is considered the normal page? Now I am getting confused.
Ken
Posted: 08/10/2002, 8:21 PM

This is the error I am getting:

Fatal error: Cannot instantiate non-existent class: clsdbconnection_name in /codes/view_events.php on line 13
Ken
Posted: 08/10/2002, 8:26 PM

It's working now!!! Thanks for the information! It dawned on me the clsdbconnection_name should be my connection name is not the name of an internal class, which is what I thought it was. I just wish you could have been more clear when you first gave me the resolution. Thanks for all your help Nicole!!!!
Karim
Posted: 09/25/2002, 1:08 PM

What would the code be for ASP+CCS if I on save/insert I grabbed the last record and added one to it, then added that number to the new record field?

Thanks
Karim

   


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

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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