Gossamer Forum
Home : Products : DBMan : Customization :

Database

Quote Reply
Database
Hi there, i´ve got a problem with my database again. I´ve defined several checkbox fields in my database. When I perform a search everything is OK and all features are shown in my report.The list appears devided with "," because I use "," as a sepperator in the list. The whole looks like this:
<TD>$rec1{'ABS'},$rec2{'ESP'}</TD> and so on.
Now I want that only values which are stored in my database (which are not empty)appear in the search results.
I´ve tried "if ($rec1{'ABS'} ne ""){$rec{'ABS'}}" but that seems not to be a valid expression and doesn´t work.
Any idea to solve that problem?
Quote Reply
Re: Database In reply to
Hey Zheon,

|; #Close previous print qq statement

if ($rec1{'ABS'}) {
print qq|{$rec{'ABS'}|;
}

Continue as normal !! Smile

Quote Reply
Re: Database In reply to
I used "|;if($rec{'ABS'}){print qq|{$rec{'ABS'}}|;}" and got a syntax error, what´s wrong??? (I´m a Perl newbie!!!)

[This message has been edited by Zheon (edited March 28, 2000).]
Quote Reply
Re: Database In reply to
Sorry 'bout that,

"|;if($rec{'ABS'}){print qq|{$rec{'ABS'}}|;}"

should probably be

"|;if($rec{'ABS'}){print qq|($rec{'ABS'})|;"
Quote Reply
Re: Database In reply to
If this does not work : "|;if($rec{'ABS'}){print qq|($rec{'ABS'})|;"

try this: |;
if($rec{'ABS'}) {
print qq|$rec{'ABS'}
|;

Hope this one works for you Smile
Quote Reply
Re: Database In reply to
Thanx Web Dog & LoisC, but both of your solutions didn´t work... ;-{
I´m not very familiar with the syntax of perl; isn't there a possibility to check if for example the var $rec{'ABS'} is not null?
The problem is, that items which are not selected for a search will appear as ",,,".
You can take a look at
www.autohaus-paassen.de/cgi-bin/match/db.cgi to see what I mean (Use "Alle Einträge")
So if i can check if the record $rec{'ABS'} is not null i can prevent the ","...

[This message has been edited by Zheon (edited March 28, 2000).]
Quote Reply
Re: Database In reply to
I had a problem like that, too. I finally used

Code:
|;
if(length($rec{'ABS'})>0) {
print qq|$rec{'ABS'}|;
}

That seemed to work for me.


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





Quote Reply
Re: Database In reply to
Hi Zheon, likely this is just a typo here on the forum however, figured I'd point it out just in case. In the first post:

I´ve tried "if ($rec1{'ABS'} ne ""){$rec{'ABS'}}"

and web dog has used that to provide the syntax in the second post
Quote:
Hey Zheon,
|; #Close previous print qq statement

if ($rec1{'ABS'}) {
print qq|{$rec{'ABS'}|;
}

Continue as normal !!

but, it seems there is a 1 missing in the first post.
if ($rec1{'ABS'} ne ""){$rec1{'ABS'}}

Please accept apologies for posting if this has been a simple typo in the post - just lurking in the forums to pick up what I can on perl - not a programmer by any stretch of the imagination Smile



------------------
~ ~ ~ ~ ~
Karen

Quote Reply
Re: Database In reply to
removed to save on space here Smile

[This message has been edited by LoisC (edited March 29, 2000).]
Quote Reply
Re: Database In reply to
removed

[This message has been edited by LoisC (edited March 29, 2000).]
Quote Reply
Re: Database In reply to
I've sorta gotten lost in all the posts. Exactly what is the problem you're having?


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





Quote Reply
Re: Database In reply to
Hi JPDeni, please take a look at my code in my previous message.

Look at the part with
"|;
if ($rec{'ABS'} eq "ABS") {
print qq|$rec{'ABS'}, |;
}
"

I used this code and the only thing i get is a script syntax error. In my previous message you can see my whole sub_html_record code. Take a look at www.autohaus-paassen.de/match/cgi-bin/db.gci and you can view the error message. None of the above solutions worked, because everytime I got a syntax error, i´m quite desperated. Perhaps you can find out whats wrong.

Greetings
Stephan, the Perl Newbie from germany...

PS: Quite cool to meet a woman which is so fascinated (of?)by programming, would be nice if there could be more of your sort ;-)

Sorry for my bad english and grammar...

[This message has been edited by Zheon (edited March 29, 2000).]
Quote Reply
Re: Database In reply to
Starting on this line
Code:
$rec{'Alarmanlage'},$rec{'ASR'},$rec{'Automatikgetriebe'},
which immediately follows the if statement you noted, there is a missing print statement... there is nothing wrong with any of the proceeding code (at least to my naked eye).

Are you using a decent code editor yet? You might find the line numbers helpful which you can correspond with the line numbers in error messages to identify where code goes astray...

Also, when posting on these boards, it is helpful to use the FORMATTING CODES to separate code from other text... click on the UBB Code link on the bottom of the post form for more info.

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

[This message has been edited by oldmoney (edited March 29, 2000).]
Quote Reply
Re: Database In reply to
One last try Smile

If you have your checkbox fields setup like this in your .cfg file:

'ABS' => 'ABS',
'Alarmanlage' => 'Alarmanlage',
'Automatikgetriebe' => 'Automatikgetriebe',
etc.

Then in your sub html_record { use:

<TD width="280"BGCOLOR="#D8D8D8"><$font_color font Size="-2">
if ($rec{'Farbe'}) { print qq| $rec{'Farbe'}, |; }
if ($rec{'Baujahr'}) { print qq| Bj. $rec{'Baujahr'}, |; }
if ($rec{'Ausstattung'}) { print qq| $rec{'Ausstattung'}, |; }
if ($rec{'ABS'}) { print qq| $rec{'ABS'}, |; }
if ($rec{'Alarmanlage'}) { print qq| $rec{'Alarmanlage'}, |; }
if ($rec{'ASR'}) { print qq| $rec{'ASR'}, |; }
if ($rec{'Automatikgetriebe'}) { print qq| $rec{'Automatikgetriebe'}, |; }
if ($rec{'Bordcomputer'}) { print qq| $rec{'Bordcomputer'}, |; }
if ($rec{'ESP'}) { print qq| $rec{'ESP'}, |; }
if ($rec{'elektr_Fensterheber'}) { print qq| $rec{'elektr_Fensterheber'}, |; }
if ($rec{'Leder'}) { print qq| $rec{'Leder'}, |; }
if ($rec{'Klimaanlage'}) { print qq| $rec{'Klimaanlage'}, |; }

print qq| <BR> |;

if ($rec{'Klimaautomatik'}) { print qq| $rec{'Klimaautomatik'}, |; }
if ($rec{'Navigationssystem'}) { print qq| $rec{'Navigationssystem'}, |; }
if ($rec{'Radio_Tape'}) { print qq| $rec{'Radio_Tape'}, |; }
if ($rec{'Radio_CD'}) { print qq| $rec{'Radio_CD'}, |; }
if ($rec{'Schiebedach_mechanisch'}) { print qq| $rec{'Schiebedach_mechanisch'}, |; }
if ($rec{'Schiebedach_elektrisch'}) { print qq| $rec{'Schiebedach_elektrisch'}, |; }
if ($rec{'Servolenkung'}) { print qq| $rec{'Servolenkung'}, |; }
if ($rec{'Sitze_elektrisch_verstellbar'}) { print qq| $rec{'Sitze_elektrisch_verstellbar'}, |; }
if ($rec{'Sitzheizung'}) { print qq| $rec{'Sitzheizung'}, |; }
if ($rec{'Telefon'}) { print qq| $rec{'Telefon'}, |; }
if ($rec{'Telefonvorbereitung'}) { print qq| $rec{'Telefonvorbereitung'}, |; }
if ($rec{'Tempomat'}) { print qq| $rec{'Tempomat'}, |; }
if ($rec{'Tiptronic'}) { print qq| $rec{'Tiptronic'}, |; }
if ($rec{'Wegfahrsperre'}) { print qq| $rec{'Wegfahrsperre'}, |; }
if ($rec{'Zentralverriegelung'}) { print qq| $rec{'Zentralverriegelung'}, |; }

print qq| </font></TD>

Just copy what you currently have in your html.pl file and put it in your text editor for safe keeping and try inserting the code above in it's place.
I really think this will work for you now. I use the exact same coding for checkbox fields in a few of my databases Smile

Be sure to change your database file to remove the commas in the current records.
Quote Reply
Re: Database In reply to
Thanx!!!!!!!!!!!!!!!
You got it, just inserted your code to html.pl and it worked as it should. Special thanx to LoisC and all the others!!!!!!!!!
Your patience with newbies like me is phenomenal! Never experienced such a fantastic support like in this forum. Love you all. Perhaps someday when I´ve improved my Perl knowledge I can help other users to mod this great database. So long, till my next question arrives

CU all
Greetings from germany
Stephan
Quote Reply
Re: Database In reply to
Here ´s my code. Sorry all of you for stealing your time, but none of your solutions did work for me. I`m always getting syntax errors when I try one of the solutions.

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.
($db_auto_generate and print &build_html_record(%rec) and return);

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

print qq|
<TABLE $table BORDER="0" bordercolor="#003399"><tr><td align="center">
<TABLE $table BORDER="3" bordercolor="#D8D8D8">
<TR><TD>|;
if ($visitor ne "Gast") {
print qq|
<a href="message/add.cgi?Message=$rec{'ID'}-$in{'uid'}"><img align="right" border="0" src="$pics/mail.gif" WIDTH="24" HEIGHT="21" ALT="Send Message"></a>
|;
}
if ($per_admin) {
print qq|
<$font>$rec{'ID'}</Font>
|;
}
if ($visitor ne "Gast") {
if ($rec{'RevealMail'} eq "Yes") {
print qq|
<A HREF="mailto:$rec{'Email'}"><acronym title="Send Email">
|;
}
}
print qq|
<$font>$rec{'NickName'}</font></acronym></A></FONT></TD><TD width="370">|;
if ($per_admin) {
print qq|
<A HREF="upload/photo.cgi?Photo=$rec{'ID'}-$in{'uid'}"><IMG border="0" align="right" SRC="$pics/photo.gif" WIDTH="31" HEIGHT="11" ALT="Upload Your Photo Here
(Size 100x150)"></a>
|;
}
#if ($rec{'RevealName'} eq "Yes") {print qq|<$font_color>$rec{'FirstName'} $rec{'LastName'}</font>|;}
#if ($rec{'RevealName'} eq "No") {print qq|$rec{'FirstName'} (Not Revealed)|;}
print qq|
</TD>
</TR>
<TR><TD>
|;
$Message = $rec{'ID'};
if ($Message ne "") {&Get_Messages;}
if ($Messages ne "0") {
if ($rec{'Userid'} eq $visitor) {
print qq|
<a href="message/mail.cgi?Message=$rec{'ID'}-$in{'uid'}"><img align="right" border="0" src="$pics/mail.gif" WIDTH="24" HEIGHT="21" ALT="You Have $Messages Messages"></a>
|;
}
}
print qq|
<TR valign="middle">
<TD width="100"valign="middle" align="right"><img src="$photo/$rec{'ID'}.jpg" ALT="Großes Bild"></TD>
<TD width="160"BGCOLOR="#D8D8D8"><$font_color><h5>$rec{'Marke'} $rec{'Modell'}</h5></font></TD>
<TD width="280"BGCOLOR="#D8D8D8"><$font_color><Font Size="-2">$rec{'Farbe'},Bj. $rec{'Baujahr'}, $rec{'Ausstattung'},
|;
if ($rec{'ABS'} eq "ABS") {
print qq|$rec{'ABS'}, |;
}
$rec{'Alarmanlage'},$rec{'ASR'},$rec{'Automatikgetriebe'},
$rec{'Bordcomputer'},$rec{'ESP'},$rec{'elektr_Fensterheber'},$rec{'Leder'},$rec{'Klimaanlage'},<BR>$rec{'Klimaautomatik'},$rec{'Naviga tionssystem'},$rec{'Radio_Tape'},$rec{'Radio_CD'},
$rec{'Schiebedach_mechanisch'},$rec{'Schiebedach_elektrisch'},$rec{'Servolenkung'},$rec{'Sitze_elektrisch_verstellbar'},$rec{'Sitzheizung'}, $rec{'Telefon'},$rec{'Telefonvorbereitung'},
$rec{'Tempomat'},$rec{'Tiptronic'},$rec{'Wegfahrsperre'},$rec{'Zentralverriegelung'}
</font></font></TD>
<TD width="85" BGCOLOR="#D8D8D8"><$font_color> $rec{'Preis'}</font></TD></TR>
</TABLE></td></tr></table>


|;
}

I`ve only changed one of the records to see what happens, but nothing then these error appears on my screen. Perhaps anohter typo???

;-(