Gossamer Forum
Home : Products : DBMan : Installation :

How to show the number of ID in the Home Page of DBMAN

Quote Reply
How to show the number of ID in the Home Page of DBMAN
Hello,

I want to put the total number of ID of my data base, in the first page.
Thanks in advance.


------------------
------------------------
mailto:greg@hermel.com
http://www.hermel.com
Quote Reply
Re: How to show the number of ID in the Home Page of DBMAN In reply to
Here's what I did. In the db.cgi, add the following:

sub num_members {
# ---------------------------------------------
# Displays the number of accounts

my $count = 0;

open (DB, "<$auth_pw_file") or &cgierr("error in num_members. unable to open database: $auth_pw_file.\nReason: $!");

LINE: while (<DB> ) {
if (!(/^#/) && !(/^\s*$/)) {
$count++;
}
}
print $count;
}

Then in your html.pl add the following wherever you want the number to be displayed:
|;&num_members;print qq|

Hope that helps.


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: How to show the number of ID in the Home Page of DBMAN In reply to
Jason,
I did what you said and it was wonderful. But I have added a few options/fields for users to fill in and dumped that database to start from scratch, but it is counting from where it left off, not starting over.

Jason Kopacko
Quote Reply
Re: How to show the number of ID in the Home Page of DBMAN In reply to
Grego, here's what you have to add to your db.cgi to count the number of records.

sub num_records {
# --------------------------------------------------------
# Displays the number of records

my $count = 0;

open (DB, "<$db_file_name") or &cgierr("error in num_records. unable to open database: $db_file_name.\nReason: $!");

LINE: while (<DB> ) {
if (!(/^#/) && !(/^\s*$/)) {
$count++;
}
}
print $count;
}

In your html.pl put |;&num_records;print qq| in where you want the number to records displayed.

kopacko, your .count file probably doesn't match the number of records in your .db - make sure that they match.

Hope that helps.


------------------
Jason
Extreme mtb
http://extreme.nas.net