Gossamer Forum
Home : Products : DBMan : Installation :

ignoring URLs in alphabetic sorting

Quote Reply
ignoring URLs in alphabetic sorting
I've got a database in which URLs are part of the data in some cases, in other cases not, like this:

<a href="http://members.aol.com/instyprnts/">Insty-Prints</a>
<a href="http://www.adpmarshall.com/">ADP Marshall Inc.</a>
University Physicians Inc.

When sorting alphabetically, the results should be:
ADP Marshall Inc.
Insty-prints
University Physicians Inc.

not
Insty-Prints
ADP Marshall Inc.
University Physicians Inc.


If someone could help me with the regular expression to ignore the URL (and where to put it in db.cgi!) I'd be grateful.

Larry

[This message has been edited by Larry Scritchfield (edited March 18, 1999).]

[This message has been edited by Larry Scritchfield (edited March 18, 1999).]
Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
Are you saying that the field contents are

<a href="http://members.aol.com/instyprnts/">Insty-Prints</a>

It would be better to have separate fields for the name and the URL. Then you can sort by the name.


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





Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
That's right. The URL is integrated with the name. The idea is to give users immediate access to the company's site.
Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
If you have them in two separate fields, you can still do that. You can use

<a href="$rec{'URL'}">$rec{'Name'}</a>

in html_record. That way you can still sort on the name field.


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





Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
Thanks, it was right there in front of me. Probably even in the README. I just needed someone to show me the way.

Now I just need to re-massage my data...

Thanks again.
Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
Whoa. When there *is no URL*, the name still
comes up clickable, with the current address of dbman as the destination.
Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
Sorry. Forgot to mention that.

In html_record, where you want to print out the URL, first close off your print statement with a |; (pipe character -- semi-colon).

Then enter

Code:
if (length($rec{'URL'} > 7) {
print qq|<a href="$rec{'URL'}">$rec{'Name'}</a>|;
}
else {
print $rec{'Name'};
}

The add "print qq|" to start the rest of your print statement.

The reason I use length($rec{'URL'} > 7 is that you might want to have the field default to "http://" and if someone doesn't have a URL, those characters will still be there.


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





Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
Something isn't working. It's going straight to the "else" statement. I put in a matching right parenthesis in the "if" condition:

Code:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Company Name:</FONT></TD>
<TD> <$font>|;
if (length($rec{'URL'} > 7)) {
print qq|<a href="$rec{'URL'}">$rec{'CompanyName'}</a>|;
} else {
print $rec{'CompanyName'};
}
print qq|</Font></TD></TR>

Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
Sorry. (I seem to be saying that a lot these days.)

Good job noticing the missing parentheses. You just got it in the wrong place. It should be

if (length($rec{'URL'}) > 7) {



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





Quote Reply
Re: ignoring URLs in alphabetic sorting In reply to
That did the trick. You're a lifesaver JPDeni. Thanks a lot.