Groups | Blog | Home
all groups > inetserver asp general > october 2004 >

inetserver asp general : Trimming filename and paramters from a URL (output from DB)


Simon
10/28/2004 4:47:25 PM
Hi there.

I seem to be a flurry of questions here recently, thanks for you help all,
but ... got another question here.

I am storing URL in a database for a 'sort of' directory type website.

The <a href> is built from the recordset of URL's which is all working no
problem, easy stuff.

What I have found is going to be necessary in some cases is to trim the URL
back to just it's www.abc.co.uk address for the link display.

I still want the actual link to go to it's long 'deep linking' location, but
there is limited room for displaying a URL that could be a hundred chars
long.

So... Just to recap.

www.abc.co.uk/products.asp?cat=1&id=234&somethingelse=12

gets trimmed back to

www.abc.co.uk

Thanks in advance.

Simon.

Simon
10/28/2004 6:22:41 PM
I got ;-)

I realised I was trimming the http:// from the inputted URL, so I only had
to search for the first / and stop there.

<%

if not rs("URL")="" then

iURL = instr(rs("URL"), "/")
if iURL then tURL = left(rs("URL"), iURL-1) else tURL = rs("URL")
fURL = tURL


%><strong>Website</strong> : <a href="http://<%= rs("URL") %>"
title="<%= fURL %>"><%= fURL %></a><br /><% end if %>

Take care

Si


[quoted text, click to view]

Evertjan.
10/28/2004 6:31:22 PM
Simon wrote on 28 okt 2004 in microsoft.public.inetserver.asp.general:
[quoted text, click to view]


fURL = replace(rs("URL"),"http://","/")

or

fURL = replace(rs("URL"),"http:/","")

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)
AddThis Social Bookmark Button