Gossamer Forum
Home : Products : DBMan : Customization :

number of records matching criteria

Quote Reply
number of records matching criteria
I have DBman set up for my fantasy football draft. I would like to keep track and report to users how many players have been drafted.

I have a field titled "PickNum" with the default of "0". The field type is set to Numer. This tracks what round the player was picked from 1-20 or 0 if he is still available.

The database has all (or most) of the players already entered in with a PickNum of 0. Once a player is picked he gets asigned an Owner and a PickNum.

What I'd like to do is a calculation that tells me how many records have "PickNum=>0" and then have that appear in the main menu.

Thanks!
Quote Reply
Re: [rickd] number of records matching criteria In reply to
If you "PickNum" field is setup as a select field than you should be able to use the mod "list categories with count" mod to do what you want.

Please check either the GT Resource Center, the FAQ noted below or JPDeni's http://jpdeni.com/dbman/ site for the mod variations.

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: [LoisC] number of records matching criteria In reply to
Thanks. I found a MOD that almost gave me what I want. I am stuck on one little easy(?) part.

Here is what I have done-

open (DB, "<$db_file_name") or
&cgierr(" unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock)
{ flock(DB, 1); }
@lines = <DB>;
close DB;

@options2 = ('QB','RB','WR','TE','K','DEF');
foreach $line (@lines) {
++$count_total;
@data = &split_decode($line);
++$count{$data[2]};
if ($data[2] gt "0") {
++$count{$data[5]};
}
}
foreach $option (@options2) {
unless ($count{$option}) {
$count{$option} = "0";
}
}
print qq|

<p> The following number of players have been drafted: <BR>
QB- $count{'QB'} ::
RB- $count{'RB'} ::
WR- $count{'WR'} ::
TE- $count{'TE'} ::
K- $count{'K'} ::
DEF- $count{'DEF'}
<BR>
$count_total -- total number of positions <BR>
<BR>
A total of $count{"1"} players have been picked<BR>
|;

The way I have the database set up is that if a player is NOT drafted, his PickNum (field 2) is "0". The mod works well for counting each position. It returns the total number of Field 5 where field 2 = greater than 0.

The one I really want though is that last one, the TOTAL number of players who have field 2 = greater than 0.

The code I have now is-

A total of $count{"1"} players have been picked

What do I need to enter there for "greater than 0"? nothing I have tried works...

The program is running here:

http://www.rickd.com/football/

Thanks!

Last edited by:

rickd: Aug 30, 2002, 12:28 PM