Gossamer Forum
Home : Products : DBMan : Customization :

blank fields

Quote Reply
blank fields
I did read FAQ's about blank fields, but I cant understand. please, anyone may explain it better?
I use the field " URL = http:// " but any times this fields is not completed, so I dont want that it appears blank.

Can anyone understand me? Sorry, I dont speak english. [you can write english!]

Thanks in advance, & regards
Marcelo
Quote Reply
Re: blank fields In reply to
I do understand that sometimes the explanations can be difficult if English is not your first language. I'll try to explain it, but let me know if it doesn't work. (I just thought of a better way to do it anyway. Smile )

First I'll explain a little bit about Perl and how things are displayed. Whatever is going to actually appear on the web page must be "printed" to the page. In most of DBMan, the statement that is used to tell the script "print this" begins with

print qq|

and ends with

|;

By using print qq|, the script can print out variables (things that start with a $, like $rec{'FieldName'}) and it can also print out quotation marks, which are necessary for things like URLs and image tags ( <a href="www.server.com/">).

Any commands that you want the script itself to execute must be outside of a print qq| statement. Otherwise, the commands will be printed on the web page and the commands will not be executed.

Does this make any sense?

If you've followed me so far, you'll have a much better understanding of what actually is happening in the script and you can work with it much better.

The subroutine that displays the record information is sub html_record. It starts with

Code:
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';

All these lines are commands for Perl. The next line starts the printout on the html page.

print qq|

You will probably have something you want to print before you check for whether something exists in a field -- <table><tr><td> tags, font tags, labels for the field -- lots of possiblities.

What I would do (if you haven't already) is to create the html_record subroutine as if every field would be printed. Don't worry at first about empty fields. If you are careful in the way you enter your field information, it will be much easier to edit later.

Here's a little example of the display portion of sub html_record for a database with four fields:

Code:
print qq|
<table>
<tr><td>ID:</td>
<td>$rec{'ID'}</td></tr>
<tr><td>Name:</td>
<td>$rec{'Name'}</td></tr>
<tr><td>Age:</td>
<td>$rec{'Age'}</td></tr>
<tr><td>URL:</td>
<td>$rec{'URL'}</td></tr>
</table>
|;

Once you have the display looking the way you want it to, then look at what you might want to leave out if the field for a particular record is blank.

Find the starting and ending points of the formatting you want to leave out. Insert three blank lines before and after that point. (If there are several fields you want to set up as optional, just do one at a time and test it before you do another one.)

Continuing with my example, I'm going to make the URL an optional field.

Code:
print qq|
<table>
<tr><td>ID:</td>
<td>$rec{'ID'}</td></tr>
<tr><td>Name:</td>
<td>$rec{'Name'}</td></tr>
<tr><td>Age:</td>
<td>$rec{'Age'}</td></tr>
 
 
 
<tr><td>URL:</td>
<td>$rec{'URL'}</td></tr>
 
 
 
</table>
|;

Go to the first blank line you made and enter |; on that line.

On the next line, enter

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

replacing FieldName with the name of the field you want to test.

On the third blank line, enter print qq|
My example will now look like

Code:
print qq|
<table>
<tr><td>ID:</td>
<td>$rec{'ID'}</td></tr>
<tr><td>Name:</td>
<td>$rec{'Name'}</td></tr>
<tr><td>Age:</td>
<td>$rec{'Age'}</td></tr>
|;
if ($rec{'URL'} gt $db_defaults{'URL'}) {
print qq|

<tr><td>URL:</td>
<td>$rec{'URL'}</td></tr>
 
 
 
</table>
|;

(Of course, yours won't have bold letters in it. I just put them there so you could see it more easily.)

Now go to the blank line after the optional section. Enter

|;

on that line.

Go to the next blank line.

Enter a

}

on that line.

Go to the other blank line and enter

print qq|

on that line. My example now looks like

Code:
print qq|
<table>
<tr><td>ID:</td>
<td>$rec{'ID'}</td></tr>
<tr><td>Name:</td>
<td>$rec{'Name'}</td></tr>
<tr><td>Age:</td>
<td>$rec{'Age'}</td></tr>
|;
if ($rec{'URL'} gt $db_defaults{'URL'}) {
print qq|
<tr><td>URL:</td>
<td>$rec{'URL'}</td></tr>
|;
}
print qq|

</table>
|;

It's all done.

Please let me know if you have any questions.


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


[This message has been edited by JPDeni (edited May 04, 1999).]
Quote Reply
Re: blank fields In reply to
Thanks very much!!!!
That's runing perfectly.
Quote Reply
Re: blank fields In reply to
Hi!. That's a prety good example. I read it and make this Mod in my sub html_record

Code:
|; if ($rec{'Reversible'} eq "Si") {
print qq| <i> ,b>Reversible</b></i><br> |;
} else {
print qq| <br> |;
}

the field Reversible is a Radio Button with two diferent values 'Si,No' defined in .cfg file.

The problem is: the sub html_record never validate the eq expression... why? i know some records have to make this code true and print the word "Reversible", but that never happend, could you tell my why?

thanks.


------------------
Gustavo.
gustavo@buscadorargentino.com
Quote Reply
Re: blank fields In reply to
Two suggestions for you, Gustavo.

In your if eval, change "Si" to 'Si'.

Another suggestion would be to get rid of your else, like this:

Code:
|;
if ($rec{'Reversible'} eq 'Si') {
print qq|<i><b>Reversible</b></i>|;
}
<BR>

--Lee

[This message has been edited by leisurelee (edited April 16, 2000).]
Quote Reply
Re: [JPDeni] blank fields In reply to
Dear JPDeni:

The explanation for this blank fields problem is excellent. And since I am a high school teacher, I would know. smile. The answer is exactly what I was looking for. Thanks. I do have a question too. Since some of the fields will not be printed (displayed) because they are blank from the db file, and if you have not put in your corrections, would this cause the research display web page to look wacked. Please go to http://www.ezwebpagedesigns.com/storage/ and you can see what I am talking about by looking at CTSPage.html or the image version - ctsscreenshot.jpg. Thank you for your continued help in setting up these programs. I for one definitely appreciate it![;)]

Sincerely,
Charles Hill
EZ Web Page Designs
Quote Reply
Re: [chill] blank fields In reply to
Well, due to the way your are displaying your fields you may want to put the field title regardless of whether there is an entry. I think you might want to format the display in a different manner to allow for blank fields and still have the results easy to read.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [chill] blank fields In reply to
Charles, not sure what has happened to the formatting on your display but it has surely gone amiss. I was able to login to your database using guest/guest and can see that you do have the fields in a table etc however, the page you've referred to visit has no formatting. Very curious to say the least. Shocked Can you save your html.pl file as a text file and upload to your server where it can be viewed? Whatever has gone wrong should be quickly identified when viewing the file.

~ Karen
Quote Reply
Re: [Karen] blank fields In reply to
Dear Karen:

This happened when I changed my sub html_record_form to reflect the db sequence of my fields, but as you saw, I lost the table format. I did as you asked, but I am not quite sure why you need the html.pl file, since it is the file for the dbman demonstation. I named my .pl files ctsapm.pl. I also put up the ctsapmcopy.pl, which is the same file, but before I made the changes to it that I mentioned above. I hope these files will help you to help me. Thank you.Wink

Sincerely,
Charles Hill
EZ Web Page Designs
Quote Reply
Re: [chill] blank fields In reply to
Hi Charles, it was the "renamed" file that I needed to see so I could see what changes you had made on the file. In sub html_record, the opening table tag is missing. You need to add:

print qq|
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>log_uid:</FONT></TD>
<TD WIDTH="80%">&nbsp;<$font>$rec{'log_uid'}</Font></TD></TR>



Also, I'm not sure why you've made this change:

$url{'email'} = $rec{'email'};
$url{'email'} =~ s/<\/?B>//g;

This should work:

<a href="mailto:$rec{'email'}">$rec{'email'}</a>

once the <b> tag is removed (serch results being bolded), which it is by using the line:

$url{'email'} =~ s/<\/?B>//g;

Those are the only unusual items I noticed at this time. Try making the changes suggested and see if that works. If there is still a problem, resave your file again (as ctsapm.pl.txt so I don't have to download it :-) and repost in this same thread.

~ Karen
Quote Reply
Re: [chill] blank fields In reply to
Charles, what program are you using to edit the files? Asking because the CTSPage.html file indicates some of your codes have ascii text codes instead of HTML code. Example:

<font size=-1>"&lt;<log_uid>>"

That segment should be:

<Font face="Verdana, Arial, Helvetica" Size=2>$rec{'log_uid'}

... according to your ctsapm.pl file anyway. :-)

If you do not have a good text editor, you may want to check out something like EditPlus http://editplus.com/ It is very easy to use and also color codes your perl files as you view them and can help you spot errors more easily.

~ Karen
Quote Reply
Re: [Karen] blank fields In reply to
Dear Karen:

I finally have some good results with DBMan. I used the configurator again to get things right. The email change that you mentioned to change was created by the configurator. I made the changes, but it resulted in the program not running, hmm.

Another error that I saw that I did was having my database file's fields in the incorrect order. I guess the program looks for the fields in a certain order, and if it is not in order, your search results look bad. As I remember, the drop down menu options you list in the ctsapm.pl file is what the program will look for. I thought the program looked for the db field names no matter where they were locatedin the sequence.
When I searched under admin my search results looked good, but then a small problem occurred, for some reason the key: log_uid field got repeated twice. This made the resulting search results become off: see ctsapm.html file. It seems to be the result of the log_date field: see ctsorderlogfile.txt. Initially, I changed the ctsorderlogfile.txt file to show this: 00:31:48, and the admin search results were ok, but when I did a search under admin, the search resulted in 6,6,00:56:08 01/24/2 for the log_uid and log_date fields, etc. My .cgi script prints the log_date like lines 6 and 7. Does this gap present a problem with the dbman program?

When I searched under guest/guest, I could not get anything. I know this has to do with my authentication setup. I have read all the forum material on authentication, but I still cannot fully understand it. [:/] I just want the guest to be able to login as guest and then, be able to view their own record based upon the Affiliate_ID field. [cool]

Well, I have said a lot, and as I have said before, thank you for your help. By the way, I use TextPad, a PC program to edit my files. I will look into using the program you recommend.

Sincerely,
Charles Hill
EZ Web Page Designs
Quote Reply
Re: [chill] blank fields In reply to
The database is read from the .cfg file. It doesn't matter what order the fields are listed in your html_record_form.

You have:

'Affiliate_ID' => [ 2, 'numer', 10, 255, 0, '', ''],


# Auth user field. This is the field position in the database used for storing the userid who owns the record. Set to -1 if not used.
$auth_user_field = 2;

This field should be set to a field that stores the user name. You have it setup as a number field.

This would cause problems with your database.

Noticed in your database file you are also using:
"<<log_uid>>","<<log_date>>","<<Affiliate_ID>>","<<first_name>>","<<last_name>> ........ etc.

If you are going to use a line like this you should comment it out so it doesn't cause problems.

I could view your cgi file to see what the date would be appearing without the full year displayed? Did you change sub get_date?

Once you make these changes you most likely will have to start with a new database, or be sure that you make the necessary changes so it will not be corrupt.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] blank fields In reply to
Dear Lois:

I made the changes that your recommended: commented out the first line, changed the owner variable to -1. Also, I have not changed anything in the date script. Still having the same problem with the double number - see The logfile that I am using for my delimited db - ctsorderlogfile.txt is created by CTSFormHandler.cgi - in http://www.ezwebapgedesigns.com/storage/ through my online form. I am trying to setup DBMan, so it can read the logfile and through its searching feature, allow guest to view those records that are appended to the Affiliate_ID#. That is why I used the Affiliate_ID# for the ownership part, which I now know from your statement, I cannot use because it is a number and not alphanumeric. I figured that If I used the Affiliate_ID#, and setup my authentications correct - still trying - I would be able to allow them to see their sales only, and not anybody elses.

Sincerely,
Charles Hill
EZ Web Page Designs
http://www.ezwebpagedesigns.com