Gossamer Forum
Home : Products : DBMan : Customization :

Combine 2 mods

(Page 2 of 3)
> > > >
Quote Reply
Re: Combine 2 mods In reply to
I did everything again just to make sure I was doing everything right and it still returns a 500 error.

Yes the 2 column still works.

This could be a very nice and simple to use little mod if we ever get the kinks worked out. If you get frustrated, I hope you will put it away and try again later.

Carol, check your PM in a couple of minutes.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
I'll tell you what. Let's gradually change the 2-column script.

First, change

Code:

if ($i%2) {
print qq|<tr><td bgcolor="#ffffff">|;
}
else {
print qq|<td bgcolor="#ffffff">|;
}

print qq|

<font face="arial, helvetica" size="2" color="#000000">
<B><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend" onMouseOver="status=('$field'); return true">
$field</a></B> <$smfont>(<font color="ff0000">$count{$field}</font>)</font><BR>

|;

if ($i%2) {
print qq|</td>|;
}
else {
print qq|</td></tr>|;

}


to

Code:

if ($i%2) {
print qq|<tr>|;
}
print qq|
<td>
<font face="arial, helvetica" size="2" color="#000000">
<B><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend" onMouseOver="status=('$field'); return true">
$field</a></B> <$smfont>(<font color="ff0000">$count{$field}</font>)</font>
</td>
|;
unless ($i%2) {
print qq|</tr>|;
}
This will still give you two columns, but it's heading towards the "more"-column mod.

Give it a try and see what happens.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
OK, that works.
http://www.fishhoo.com/.../reports/records.cgi

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Cool.

Right now, you have a number of items that is evenly divisible by 4. That's good. Smile

Replace

Code:

if ($i%2) {
print qq|<tr>|;
}
with

Code:

if ($i%4 == 1) {
print qq|<tr>|;
}
and replace

Code:

unless ($i%2) {
print qq|</tr>|;
}
with

Code:

unless ($i%4) {
print qq|</tr>|;
}
Give that a shot. If that works, we'll work on getting it to go when the number of states is not evenly divisible by 4.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
OK, that worked perfectly.
http://www.fishhoo.com/.../reports/records.cgi

What's next? Wink

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Way cool!!! Cool

If you want to see what the next bit does, first add a record to your database that includes a state not listed already. (Maybe you could make it Washington, in my honor. Wink)

The table will probably look funky and may not show up at all, especially if you're using Netscape. The reason is that there won't be a closing </tr> tag for your last row.

Now delete that record, because I want to be sure the following code works when there is an even number of records.

There's a bit in your code that looks like

Code:

++$i;

}


print qq|</table>|;
After the } above, add

Code:

if (($i-1)%4) {
for ($k=3;$k>= (($i-1)%4); --$k) {
print "<td>&nbsp;</td>";
}
print "</tr>";
}
Add the code in and then run it again. You shouldn't see any change.

Then add another record to your database that has a state not listed already. Run it again and see if it works better.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
Looking good so far, even in Netscape.
http://www.fishhoo.com/.../reports/reports.htm. Did spot something else weird in NS though. Glad I looked.

Will continue with instructions.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
OK, you've got it down now. It's working. Thanks a real bunch. You can see your Washington fishing report at http://www.fishhoo.com/.../reports/reports.htm.

Is this going to work with 3 columns or 5 columns or whatever?

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Great!!! Smile (Spit on your worm!!!!! Laugh)

This should work with just about any number of columns, but you'll need to change some things.

Obviously, you need to change every instance of 4 to the number of columns you want. Also, you'll need to change

for ($k=3;$k>= (($i-1)%4); --$k) {

to be one less than the number of columns you want.

If you'd like to continue refining this, we can. (Also, you'll see how I work. Make a small change, test it out, make another small change, test it out. It's tiresome, but a lot less frustrating in the long run.)

If you want to further refine it so that you can use just one script no matter how many columns you want to use, first change all instances of 4 to a variable. The changes you need to make are in red.

Code:

$in{'col'} = 4;
$i = 1;

print qq|<table align="left" border="0" cellpadding="1" cellspacing="7">|;

foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
if ($i%$in{'col'} == 1) {
print qq|<tr>|;
}
print qq|
<td>
<font face="arial, helvetica" size="2" color="#000000">
<B><a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&sb=1&so=descend" onMouseOver="status=('$field'); return true">
$field</a></B> <$smfont>(<font color="ff0000">$count{$field}</font>)</font>
</td>
|;
unless ($i%$in{'col'}) {
print qq|</tr>|;
}
++$i;
}

if (($i-1)%$in{'col'}) {
for ($k=$in{'col'}-1;$k>= (($i-1)%$in{'col'}); --$k) {
print "<td> </td>";
}
print "</tr>";
}
print qq|</table>|;
Test that out and see if it gives you the same results

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
Great!!! I'll test this in the AM and let you know. Think I can delete your fishing report now?????

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Yeah, you can delete my fishing report. I sorta hate to see it go, though. Wink

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
This works like a dream. I have tested it with 3, 4 and 5 columns. It gave perfect result each time. Anyone who wants the final product can find it at http://www.fishhoo.com/team/recordscgi.txt.

An enormous Thanks & Hug to JPDeni.



Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
You can do more with it if you want to. If you would like to set it up so that you can decide "on the fly" how many columns you want and what category to list, we can do that.

Then again, if you're happy with what you have, there's no need to mess with success! Wink

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
If you would like to push on, it's OK by me. I'm sure others would like to see it as versatile as possible.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Okey-dokey. Smile

We're going to do three new things here.

First, add the following to your script:

Code:

sub parse_form {
# --------------------------------------------------------
# Parses the form input and returns a hash with all the name
# value pairs. Removes SSI and any field with "---" as a value
# (as this denotes an empty SELECT field.

my (@pairs, %in);
my ($pair, $name, $value);

@pairs = split(/&/, $ENV{'QUERY_STRING'});

PAIR: foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ s///g;
$in{$name} = $value;
}
return %in;
}
Right at the beginning of your script, add

%in = &parse_form;

Take out the line

$in{'col'} = 4;

In your SSI call, add this to the end of the URL

?col=4

That should give you exactly the same thing as you have already. The advantage is that you can change the number of columns by editing the SSI call rather than the script. If it works like it should do, the next step will be being able to change the category name and even the database.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
I'm afraid something is not just right. I get the error "An error occured processing this directive."

The revised records.cgi is at http://www.fishhoo.com/team/new-recordscgi.txt and the .html file containing the SSI call is at http://www.fishhoo.com/team/reportshtm.txt.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
The first thing I see is that the line

%in = &parse_form;

needs to be moved up. It should be right after the last line of ############## characters.

(I don't think that should cause the problem, though.)

The syntax of the file is all right. And it looks like the SSI call is correct.

Maybe it just won't work. It was a thought. Smile

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
I'll try moving that line but I really can't ever remember seeing an SSI call used this way.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Yeah. I just was hoping that it would work. See? I told you I didn't know about SSI! Smile

It would work if it was CGI. Oh, well.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
Changing that line did not help. I'm going to consider the final version, the one located at http://www.fishhoo.com/dbmods/recordscgi.txt. This can be it's permanant home.

Thanks again for all your HELP WITHOUT ATTITUDE and check your PM.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
I have spotted one little quirk in this script that you may want to address before we call it finished. When I display my list of states, I find that reports under Kansas include reports from Arkansas. I assume that is because the word "kansas" is included in the word "arkansas." It does not happen vise versa. This is the only instance of this problem I have spotted but there could be others.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Oh, yeah.

In your link to the records, include &ww=1. That will get rid of the Arkansas/Kansas thing. What it won't get rid of, though, is a problem you might have with West Virginia/Virginia. I know I fixed that for someone in the past, but I don't remember what I did. It's not on the forum, either, because this was a private client.

I'll see if I can remember what it was.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Combine 2 mods In reply to
That will need to be put into records.cgi

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
Adding &ww=1 fixed that problem as you said it would. If you can remember the other solution I will add it and enter the mod into the Resource Center on Monday.

Will
Webmaster
FishHoo! Search Index for Fishermen
http://www.fishhoo.com/
Quote Reply
Re: Combine 2 mods In reply to
If I remember correctly, it's something that has to be done specifically for those states -- coding in sub query. Unless you were able to use the "exact match" mod that is in the forum somewhere. I'll take a look and see if I can find it.

JPD
http://www.jpdeni.com/dbman/
> > > >