Gossamer Forum
Home : Products : DBMan : Customization :

Maximum Field Value

Quote Reply
Maximum Field Value
Hi. Does anybody know the propper way to determine the maximum value for a field in a list of returned results? I'd like to be able to, in the function html_record, be able to do some conditional formatting if the returned record has the maximum value for a particular field. Would it be done as the records are being parses and the setting of a new variable?

Thanks,

Monty Lewis
Quote Reply
Re: [mlewis] Maximum Field Value In reply to
I think this is what you want - do this under html_record:

<HTML> and more stuff here
|; if ($rec{'field'} eq "bob") {
print qq|Hello Bob|;
}
else {
print qq|Hey! You're not Bob|;
}
print qq|
rest of tags and stuff here
</HTML>

(You can leave off the else part if you wish).

Use any of the following (and many more):
($rec{'field'} eq "bob") [equals]
($rec{'field'} > "bob") [greater than]
($rec{'field'} >= "bob") [greater or equal to]
($rec{'field'} < "bob") [less than]
($rec{'field'} <= "bob") [less than or equal to]
($rec{'field'} =~ /bob/) [contains]
($rec{'field'} =~ /(bob|sue|joe)/) [contains in list]
Quote Reply
Re: [Watts] Maximum Field Value In reply to
Thanks Watts, but do you know how to find the maximum value of a returned field? Thanks, Monty
Quote Reply
Re: [mlewis] Maximum Field Value In reply to
I don't think so... the only way I would know to do it is like the examples above. In other words, I'd have to already know what value I was looking for and then test the field for that number.

Example, if I allow only those over age 18 to see a link or something I'd have to do something like:

if ($rec{'age'} > "17") {print qq| link goes here |;}
else {print qq|Restricted Access|;}

Sorry I couldn't be of more help.

Last edited by:

Watts: Apr 13, 2004, 3:58 PM
Quote Reply
Re: [Watts] Maximum Field Value In reply to
I'm not sure I understand exactly what you are trying to do but this thread reference came to mind:

Limiting character display in short/long mod

Thread reference: http://gossamer-threads.com/scripts/forum/resources/Forum12/HTML/002783.html
Topic: short/long display mod
Scouser - April 26, 2000
----------------------------
Question:

Is there someway of cutting descriptions that are shown in the short display to say 50 letters.
----------------------------------------------------
Response:

If you want just 50 characters of a field to show in the short display,

after: my (%rec) = @_;

add code:

if (length($rec{'Description'}) >50) {
$rec{'Description'} = substr($rec{'Description'},0,50);
$rec{'Description'} .= "...";
}

I wasn't clear on whether you were just trying to limit the amount of information in the display or not??

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/