Gossamer Forum
Home : Products : DBMan : Customization :

Search for the first letter of a field

Quote Reply
Search for the first letter of a field
Hi guys,
Does anyone know hoe to search for the first letter of a field?

For example, I have a last name field. I originally did a search for the Capitol letter which worked great until I ran into something like McDonald which shows up in the M's and the D's.
Quote Reply
Re: Search for the first letter of a field In reply to
Thanks Eliot,
But that's not what I'm looking for. I think you read my post too fast Smile
Quote Reply
Re: Search for the first letter of a field In reply to
I think what you are looking for is a way for people to search EXACT values in fields, right?

Well, try the following:

Edit the Whole Words (ww) search option in the sub query routine in the db.cgi with the following codes:

Code:
($in{'ww'}) and ($tmpreg = "^$tmpreg\$");

Then call the ww argument in either of the following methods:

Hidden Field

Code:
<input type="hidden" name="ww" value="on">

Search Option

Code:
<input type="checkbox" name="ww" value="on">Check here for Exact Word Search

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Search for the first letter of a field In reply to
Well, the result is the same. If you search for Mc Donalds, you will only get Mc Donalds rather than listing this in the M's and D's.

Oh well...Just thought I would provide you a suggestion that works...may be not ideally how you like it. If not, may be some one else will help.

Good luck.

Wink

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Search for the first letter of a field In reply to
Oh, I see where you are getting at. I have a home page that has a linkable letter for each letter of the alphabet. So if you click on D, you'll get:
Daniels
Davidson
Dundalinger
etc..

Problem is, McDonald is also listed in the D's.
Quote Reply
Re: Search for the first letter of a field In reply to
Why not go after the first letter in the field instead of the capital letters or failing that the first letter that is also a capital letter?

------------------
JGU

Quote Reply
Re: Search for the first letter of a field In reply to
Yeah, that's what my original question is. How do I search for the first letter.
Quote Reply
Re: Search for the first letter of a field In reply to
Follow Eliots advice but use something like:

($in{'ww'}) and ($tmpreg = "\^$tmpreg");

this should have you searching the first nonwhite space in the field.

------------------
JGU



[This message has been edited by jury (edited November 01, 1999).]

[This message has been edited by jury (edited November 01, 1999).]
Quote Reply
Re: Search for the first letter of a field In reply to
Katana Man:

I had the same question some weeks back and Carol gave me this very nice bit of code:

Code:
$i = 65;
while ( $i < 91 ) {
print qq| <font face="Arial" size="2">[<A HREF="$db_script_link_url&sb=11&fieldname=%5E|;
print chr($i);
print qq|&re=on&view_records=1">|;
print chr($i);
print qq|</a>]</font>\n|;
$i++;
}

-this will do the entire thing for you .. including the creation of links [A][C][D]..etc.

just change the section &sb=11&fieldname to the number and name of the field you want to sort by (it will sort it alphabetically too) and put it somewhere in html.pl

and thats all you have to do!

hope this helps
-frank


[This message has been edited by FLThiak (edited November 02, 1999).]
Quote Reply
Re: Search for the first letter of a field In reply to
Ooh yes..thanks FLThiak and JPDeni. That worked nicely.