Gossamer Forum
Home : Products : DBMan : Customization :

searching first two characters of numerical value

Quote Reply
searching first two characters of numerical value
Hi,
The field I want to search with dbman is a zip code field and I want to search only the first two characters to get results in the surrounding. Eg if zipcode is 2347ZZ I want this zip code to show up when user searches for 23 .....but not for 34! How can i do this, thanks in advance for the help.

Kind regards,

SeP

Quote Reply
Re: searching first two characters of numerical value In reply to
In the search field, enter

^23

and check the Regular Expression checkbox.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: searching first two characters of numerical value In reply to
Thanks for your very fast reply, but I forgot to mention that I'm searching from a seperate html file the code of that file is:
<form method="get" action="http://www.huiswerkbegeleiding.nl/cgi-bin/dbman/db.cgi" name="zoek">
<input type="hidden" name="db" value="bijles">
<input type="hidden" name="uid" value="default">
Eerste twee cijfers van uw postcode: <input type="text" name="Postcode" size="2" cs=1>
<BR><select name = "Vak">
<option value= "---" selected>Selecteer een vak
<option value="Nederlands">Nederlands
<option value="Engels">Engels
<option value="Frans">Frans
<option value="Spaans">Spaans
<option value="Duits">Duits
<option value="Grieks">Grieks
<option value="Latijn">Latijn
<option value="Wiskunde">Wiskunde
<option value="Natuurkunde">Natuurkunde
<option value="Scheikunde">Scheikunde
<option value="Biologie">Biologie
<option value="ANW">ANW
<option value="Informatiekunde">Informatiekunde
<option value="Geschiedenis">Geschiedenis
<option value="CKV">CKV
<option value="KCV">KCV
<option value="Aardrijkskunde">Aardrijkskunde
<option value="Economie">Economie
<option value="Maatschappijleer">Maatschappijleer
<option value="Filosofie">Filosofie
<option value="Verzorging">Verzorging
<option value="Techniek">Techniek
<option value="Muziek">Muziek

</select>

now I want to change the text field named postcode to make it search for only the first two characters of the database field named postcode, could you tell me how to do that?

Thanks very much in advance.

Kind regards,

Sebastiaan Terpstra

ps. I am using dbman with multiple functions on my site http://www.huiswerkbegeleiding.nl check it out if you like.


Quote Reply
Re: searching first two characters of numerical value In reply to
You can add the following to sub query in the db.cgi file.

After

local (%sortby);

add

Code:

if ($in{'Postcode'}) {
$in{'Postcode'} = '^' . $in{'Postcode'};
$in{'re'} = 1;
}

JPD
http://www.jpdeni.com/dbman/
Quote Reply
THANKS In reply to
Thank you very much for this great help, if I can ever do something for you...It works great like this

Quote Reply
Re: THANKS In reply to
I'm glad I could help. (That was an easy one!! Smile)

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