How could I display on an html page the current number of records in a database automatically?
Do you want this to appear within the pages created by DBMAN? Or do you want to have this appear on a static web page outside of DBMAN?
If it is the former, then you can the add the following sub-routine in your db.cgi file:
# --------------------------------------------------------
# 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;
}
Then in your html_records or html_home (basically any sub-routine that you want to post the total number of records), place the following codes:
|; &num_records; print qq|
HTML CODES
If it's the latter, it could possibly be done through SSI (Server Side Includes) codes.
Regards,
------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
If it is the former, then you can the add the following sub-routine in your db.cgi file:
Code:
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;
}
Then in your html_records or html_home (basically any sub-routine that you want to post the total number of records), place the following codes:
Code:
HTML CODES |; &num_records; print qq|
HTML CODES
If it's the latter, it could possibly be done through SSI (Server Side Includes) codes.
Regards,
------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Aug 27, 1999, 7:34 AM
Veteran / Moderator (8669 posts)
Aug 27, 1999, 7:34 AM
Post #4 of 6
Views: 2001