Gossamer Forum
Home : Products : DBMan : Customization :

Formatting Search results

Quote Reply
Formatting Search results
I need some major help to overcome such a simple problem.
I am running dbman to hold files for mobile phone downloads.

The database search record provides 3 options tones, graphics and software. I have got the output html to list the found list and show the graphic it links to but where a non graphic file is found the SRC alt message appears and looks untidy.

If this sounds confusing try the database and see for your self what is happening.

paul
Quote Reply
Re: Formatting Search results In reply to
What is they syntax you are using for the files?

I'll need you to post the URL of the database in order to see what it's doing.


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





Quote Reply
Re: Formatting Search results In reply to
http://www.phonefx.org.uk

the code i'm using for the results out html is:

<TABLE WIDTH="90%" BORDER="0">
<TR>
<TD WIDTH="120" VALIGN="TOP" ALIGN="LEFT"><A
HREF="http://www.phonefx.org.uk/data/$url$rec{'filename'}"><IMG
SRC="http://www.phonefx.org.uk/data/$url$rec{'filename'}"
ALT="DOWNLOAD" BORDER="0"></A></TD>
<TD WIDTH="150"><$font>$rec{'filename'}</font></TD>
<TD WIDTH="200"><$font>$rec{'description'}</font></TD>
<TD WIDTH="100"><$font>Bytes: $rec{'size'}</font></TD>
</TR>
</TABLE>

The 'filename' field name links to either a graphic or non graphic file.
(although not shown in this output, the other field is 'type' Which can contain 1 of 3 options: 'tone', 'grafix' or 'software')

In simple terms, i guess i need:-

if 'type' = graphic use the above output

but

if 'type' = software or tone use another output which calls a default image or icon.

hope this makes sense, paul
Quote Reply
Re: Formatting Search results In reply to
Code:
|;
if ($rec{'type'} eq "graphic") {
print qq|the output for a graphic file|;
}
elsif ($rec{'type} eq "tone") {
print qq|the output for a tone file|;
}
elsif ($rec{'type} eq "software") {
print qq|the output for a software file|;
}
print qq|

I would put this whole thing in place of

Code:
A
HREF="http://www.phonefx.org.uk/data/$url$rec{'filename'}">
<IMG
SRC="http://www.phonefx.org.uk/data/$url$rec{'filename'}" ALT="DOWNLOAD" BORDER="0">
</A>



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





Quote Reply
Re: Formatting Search results In reply to
Thank you. So close now !
I have assembled the whole output file thus:-

sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
$rec{$db_key} =~ s/<?.B>//g;
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="tahoma, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="tahoma, Helvetica" Size=2';

print qq|
<BODY>
<TABLE WIDTH="90%" BORDER="0">
<TR>

|;
if ($rec{'type'} eq "Tone") { print qq|<A
HREF="http://www.phonefx.org.uk/data/$url$rec{'filename'}"><IMG SRC="http://www.phonefx.org.uk/data/148.bmp"
ALT="DOWNLOAD" BORDER="0"></A>|;}

elsif ($rec{'type} eq "Grafix") { print qq|<A
HREF="http://www.phonefx.org.uk/data/$url$rec{'filename'}"><IMG
SRC="http://www.phonefx.org.uk/data/$url$rec{'filename'}"
ALT="DOWNLOAD" BORDER="0"></A>|;}

elsif ($rec{'type} eq "software") { print qq|<A
HREF="http://www.phonefx.org.uk/data/$url$rec{'filename'}"><IMG SRC="http://www.phonefx.org.uk/data/148.bmp"
ALT="DOWNLOAD" BORDER="0"></A>|;}print qq|


<TD WIDTH="150"><$font>$rec{'filename'}</font></TD>
<TD WIDTH="200"><$font>$rec{'description'}</font></TD>
<TD WIDTH="100"><$font>Bytes: $rec{'size'}</font></TD>
</TR>
</TABLE>|;
}


Ok, I can see what you've done and it looks good.
so now if the field 'type' contains either the phrase 'Tone' or 'Software' it should print the default graphic 148.bmp.
If 'Grafix' then the respective graphic image will display.

An error is reporting as a result.

But i'm not familiar with cgi/perl syntax. Have I missed something?

Paul
Quote Reply
Re: Formatting Search results In reply to
My fault. I made a typo.

In each case, it should be

Code:
$rec{'type'}

not

Code:
$rec{'type}

If you fix that, your subroutine will run. (I just checked it for other syntax errors. Smile )

Sorry 'bout that.


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





Quote Reply
Re: Formatting Search results In reply to
Perfect !

That's teamwork. Thanks J'

Paul