Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - If RecordField is empty then goto...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

If RecordField is empty then goto...

 Post Reply Post Reply
Author
Arguich811 View Drop Down
Newbie
Newbie
Avatar

Joined: 14 March 2003
Location: Netherlands
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arguich811 Quote  Post ReplyReply Direct Link To This Post Topic: If RecordField is empty then goto...
    Posted: 14 March 2003 at 5:58pm

Hello,

I use the following method to get the hyperlinks from a recordfield in a database written into my page:
...
Response.Write ("<a class='b' href='" & rsQuery("pub_url") & "' target='_blank'>")Response.Write (".&nbsp;<i>" & rsQuery("title") & "</a></i>.&nbsp;")
...
In some cases however, there is no hyperlink, i.e.: the recordfield ('pub_url') is empty.  In that case, I want to the 'empty string' to be replaced by a link to a 'redirection-page', similar to a custom 404 page, so something like:

If rsQuery("pub_url") = empty then rsQuery("pub_url") = "redirect.htm"

However, I do not know how to do this.

anyone got an idea?

Armand

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2003 at 6:06pm

<%
IF isNull(rsQuery("pub_url")) or rsQuery("pub_url") = "" THEN
str_page = "redirect.htm"
else
str_page = rsQuery("pub_url")
end if
%>


<a href="<%=str_page%>">click</a>

Back to Top
Arguich811 View Drop Down
Newbie
Newbie
Avatar

Joined: 14 March 2003
Location: Netherlands
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arguich811 Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2003 at 6:47pm

Thanks for this quick reply,

I translated your suggestion into:

...
Dim str_page
IF isNull(rsQuery("pub_url")) or rsQuery("pub_url") = "" THEN
str_page = "redirect.htm"
else
str_page = rsQuery("pub_url")
end if
...


...
Response.Write ("<a class='b' href='" &  str_page & "' target='_blank'>")
Response.Write (".&nbsp;<i>" & rsQuery("title") & "</a></i>.&nbsp;")
...

But this doesn't work because it writes the same fieldvalue for rsQuery in each record. I'm  probably still doing something wrong, but what?

Armand

Back to Top
Arguich811 View Drop Down
Newbie
Newbie
Avatar

Joined: 14 March 2003
Location: Netherlands
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arguich811 Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2003 at 7:02pm

Sorry,

My mistake: I placed your script ABOVE the statement:

Do While not rsQuery.EOF

So obviously the code did not run. Thanks again, for your help.

 

Armand

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.