Gossamer Forum
Home : Products : DBMan : Installation :

Empty fields not to be displayed

Quote Reply
Empty fields not to be displayed
Greetings:

This excellent idea should give the search results a cleaner look and may even speed things up a little, no?

Does the following have to be set and repeated for each field according to the field name?

Exactly where in the html.pl (?) should it go?

Thanks much.

----

I have done it like this:
|;

if ($rec{'Whatever_Field'} ne "") {print qq|

$rec{'Whatever_Field'}

|;}

print qq|
JPDeni posted February 13, 1999 11:57 PM PST           
------------------------------------------------------------------------
There's plenty of ways to write the same thing in Perl, but I prefer the
"positive" approach:
if ($rec{'FieldName'}) {
print qq|whatever|;
}





Quote Reply
Re: Empty fields not to be displayed In reply to
I'm afraid it does have to be repeated for every field that might be empty.

You would put it in html.pl within the html_record subroutine.

Be sure to close off the print qq| before you use the "if" statement. (Did that sound like Greek to you? Sorry. Smile )

Your html_record subroutine should look something like:
Code:
print qq|<TABLE>
<TR><TD>FieldName1:</TD>
<TD>$rec{'FieldName1'}</TD></TR>
<TR><TD>FieldName2:</TD>
<TD>$rec{'FieldName2'}</TD></TR>
<TR><TD>FieldName3:</TD>
<TD>$rec{'FieldName3'}</TD></TR>
[and so one through all your field names]
</TABLE>|;

If you want to make a fieldname optional, it would be something like

Code:
print qq|<TABLE>
<TR><TD>FieldName1:</TD>
<TD>$rec{'FieldName1'}</TD></TR>|;

if ($rec{'FieldName2'}) {
print qq|

<TR><TD>FieldName2:</TD>
<TD>$rec{'FieldName2'}</TD></TR>|;
}
print qq|

<TR><TD>FieldName3:</TD>
<TD>$rec{'FieldName3'}</TD></TR>
[and so one through all your field names]
</TABLE>|;

------------------
JPD


[This message has been edited by JPDeni (edited February 20, 1999).]