Gossamer Forum
Home : Products : DBMan : Customization :

Making link in display for variable with spaces.

Quote Reply
Making link in display for variable with spaces.
Is it possible to make a link that will show up when a record is found that will search the database even if the variable's result is two or three words with a space in between? For example, in sub html_record I can place a link for my "place" field with
<a href="http://www.myurl.com/dbman/db.cgi?db=default&uid=default&ID=&Title=&URL=&Type=---&Date=&Category=---&Description=&keyword=$rec{'place'}&mh=1&sb=---&so=ascend&view_records=View+Records&nh=11">$rec{'place'}</a>

However, if the result of the Place record is more than one word, like "Park Place" the resulting link is http://www.myurl.com/dbman/db.cgi?db=default&uid=default&ID=&Title=&URL=&Type=---&Date=&Category=---&Description=&keyword=Park Place&mh=1&sb=---&so=ascend&view_records=View+Records&nh=11
which will not search properly because of the space between "Park" and "Place."

Thank you.

Quote Reply
Re: Making link in display for variable with spaces. In reply to
If you're only going to have spaces that need coding, before you print out the link, add

$place=$rec{'place'};
$place =~ s/ /+/g;
print qq|<a href="$db_script_link_url&keyword=$place&mh=1&view_records=1&nh=11">$rec{'place'}</a>|;


If there might be other odd characters that give you a problem, you'll need to go to http://www.jpdeni.com/dbman/Mods/changes.txt and add the subroutine at the bottom of the page -- sub urlencode. If you do that, you would use

$place=&urlencode($rec{'place'});
print qq|<a href="$db_script_link_url&keyword=$place&mh=1&view_records=1&nh=11">$rec{'place'}</a>|;


(I'm not quite sure about why you're using "&nh=11" but mine is not to wonder why! Smile)

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