Gossamer Forum
Home : Products : DBMan : Customization :

Displaying the total number of records

Quote Reply
Displaying the total number of records
Hey All...

I am able to get the script to display the total number of records. What I would like to know, can I display that info on a regular HTML page. The 'regular' page is one that does not have any dbman, or any cgi connected to it.

The reason I would like to do this, is I would not have to copy or do any HTML coding in my .pl file, since it is already done

thanks
david
Quote Reply
Re: Displaying the total number of records In reply to
If your server allows SSI calls, then you can simply add the following codes on your ssi enabled web page.

Code:
Total Records: <!--#include virtual="/cgi-bin/dbman/default.count"-->

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Displaying the total number of records In reply to
Two things:
1) IF I include that code does it go within a qq| | block? If so my provider does not support includes.

2) Is there a way to gather this as dbman opens the default.db file?

thanks

joeh
Quote Reply
Re: Displaying the total number of records In reply to
In terms of the codes I gave, that is for a NON GENERATED DBMAN page using SSI calls!

In terms of putting record numbers in your DBMAN generated home page, you can add the following codes to 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*$/)) {
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
}
++$count;
}
close DB;
print $count;
}

Then call this routine in your sub html_home routine in your html.pl with the following codes:

Code:
|;
num_records;
print qq|

Regards.

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited December 07, 1999).]

[This message has been edited by Eliot (edited December 08, 1999).]
Quote Reply
Re: Displaying the total number of records In reply to
Just so you're not mislead, the following has nothing to do with displaying the "actual total" number of records.

Quote:
If your server allows SSI calls, then you can simply add the following codes on your ssi enabled
web page.

code:


Total Records: <!--#include virtual="/cgi-bin/dbman/default.count"-->

default.count is merely a place holder file to denote the next record ID assigned - it does not account for deleted records or if say you wanted to start numbering your records beginning with 1000 you merely initialize your default.count with the value 1000

hope this helps.
Quote Reply
Re: Displaying the total number of records In reply to
In terms of the info I gave and his original question
Quote:
I am able to get the script to display the total number of records. The 'regular' page is one that does not have any dbman, or any cgi connected to it.

your solution for the SSI call was merely incorrect, that's all. He CAN'T display "total records" on a static page using your SSI call or as he puts it "one that does not have any dbman, or any cgi connected to it"

He MUST use a proper SSI call utilizing a sub-routine similar to the one you offer and output that to a static .shtml page otherwise he is forced to "cut-n-paste" a total which is what he doesn't want to do.

I've done all I can do to explain - you're on your own.
Quote Reply
Re: Displaying the total number of records In reply to
The mod above is missing a close bracket. Add it here:
Code:
}
++count;
Quote Reply
Re: Displaying the total number of records In reply to
Thank you for pointing out the syntax error, oldmoney.

hooter,

Thank you for the suggestions.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------