Gossamer Forum
Home : Products : DBMan : Installation :

skipping over email and URL fields without data

Quote Reply
skipping over email and URL fields without data
I've put in the code (in html.pl) to skip over unused fields but it isn't working on my email and url fields. Why not and how do I do this - below is the code I've put in sub html_record for the email field:

Thanks,
Code:
print qq|







|;



if ($rec{'Email'} gt $db_defaults{'Email'}){



print qq|



<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email: </FONT></TD>

<TD> <$font><A HREF="mailto:$rec{'Email'}">$rec{'Email'}</A></Font></TD></TR>





|;



}
Quote Reply
Re: [jury] skipping over email and URL fields without data In reply to
You can't say "if Email1 is greater that Email2" - it makes no sense. You need to rethink the method of skipping empty fields.

The best way would be to loop through %rec and use "next" if the $rec value is 0 or empty.

Last edited by:

RedRum: Nov 6, 2001, 5:23 AM
Quote Reply
Re: [jury] skipping over email and URL fields without data In reply to
You can simply use:

|;
if ($rec{'Email'}) { print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email:</FONT></TD>
<TD> <$font><A HREF="mailto:$rec{'Email'}">$rec{'Email'}</A></Font></TD></TR>
|;
}

And so that you can still define a URL in your .cfg file to default to showing http:// for example:

'URL' => [11,'alpha',30,90,1,'http://','^http://'],

You can use as an example:

if (length($rec{'URL'}) > 7) { print qq| URL: <B><A HREF="$url{'URL'}" target="blank">$rec{'URL'}</A></B><BR> |; }

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [jury] skipping over email and URL fields without data In reply to
A much more efficient way requiring much less html and perl code would be:

Code:
foreach (keys %in) {
next if !$rec{$_} or ($rec{$_} == '0') or ($rec{$_} eq 'http://');
if (/^Email$/) {
print qq|<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email: </FONT></TD><TD> <$font><A HREF="mailto:$rec{Email}">$rec{Email}</A></Font></TD></TR>|;
}
else {
print qq|<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>$_: </FONT></TD><TD> <$font>$rec{$_}</Font></TD></TR>|;
}
}

Last edited by:

RedRum: Nov 7, 2001, 4:54 AM
Quote Reply
Re: [RedRum] skipping over email and URL fields without data In reply to
That should be foreach (keys %rec) {
Quote Reply
Re: [RedRum] skipping over email and URL fields without data In reply to
Looks like both more coding and more html ??

Why not just edit your previous post rather than making another with corrections. Also since you didn't bother to provide a solution to begin with, why bother answering now?


Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] skipping over email and URL fields without data In reply to
Quote:
Looks like both more coding and more html ??

The code I provided above will create the output for the whole of sub record_form whereas yours (which is about the same length) only deals with the email issue.

Quote:
Why not just edit your previous post rather than making another with corrections

I'd like to be able to edit posts after 60 minutes but unfortunately I can't - note the posting times of my posts

Quote:
Also since you didn't bother to provide a solution to begin with, why bother answering now?

I provided a suggestion in my original reply but in an attempt to be more helpful I decided to come back to provide the code for my suggestion. Also this is a public forum so I can reply whenever I like.

Now lets get back to the thread topic.

Last edited by:

RedRum: Nov 7, 2001, 2:21 PM