Gossamer Forum
Home : Products : DBMan : Customization :

Display and image if there is a record in the DB.

Quote Reply
Display and image if there is a record in the DB.
I'm trying to get a number of how many records are in the DB I call toby to show on the master page.
Below is the code that I'm using, the path to "toby.db" is correct but I don't get a number to show.

What my end goal is, is to have and image show on a page (like a red bar) if there is one record or more in the data base
If there are no records then the image will not show.
Records are in this DB for a short time then deleted. The red bar will tell admin that there is a record in the DB.

You may know of a better way than what I'm thinking.

Any ideals?
Ed-

################################################################
cfg
################################################################

# Full path to toby database.
$db_file_toby = $db_script_path . "/../db/toby.db"; # This is the name of the Toby's DB.


################################################################
db.cgi
################################################################

sub db_record_count {
# --------------------------------------------------------
# Displays the number of records.

my $count = 0;
open (DB, "<$db_file_toby") or &cgierr("error. unable to open database:$db_file_toby.\nReason: $!");
LINE: while ( ) {
if (!(/^#/) && !(/^\s*$/)) {
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($per_admin) {
++$count;
}
}
}
close DB;
print $count;
}


################################################################
html.pl
################################################################

This is a test to see if it will print a number: $db_record_count
Subject Author Views Date
Thread Display and image if there is a record in the DB. knue 6834 Dec 29, 2015, 2:10 PM
Thread Re: [knue] Display and image if there is a record in the DB.
delicia 6657 Dec 30, 2015, 8:12 AM
Thread Re: [delicia] Display and image if there is a record in the DB.
delicia 6653 Dec 30, 2015, 8:18 AM
Thread Re: [delicia] Display and image if there is a record in the DB.
knue 6644 Dec 30, 2015, 4:33 PM
Post Re: [knue] Display and image if there is a record in the DB.
delicia 6623 Dec 30, 2015, 6:36 PM
Post Re: [knue] Display and image if there is a record in the DB.
Andy 6612 Dec 30, 2015, 10:24 PM