| Author |
Problems with variable code
|
|
| AlanShaw 2005-03-09, 6:19 pm |
| Any ideas on how to make this work would be appreciated. It fails at the 'line
break'
<% If rsRobtest.Fields.Item("mlAddress1").Value)<>"" Then Responce.Write
Recordset("mlAddress1") & "br /">
<% If rsRobtest.Fields.Item("mlAddress2").Value)<>"" Then Responce.Write
Recordset("mlAddress2") & "br /">
<% If rsRobtest.Fields.Item("mlAddress3").Value)<>"" Then Responce.Write
Recordset("mlAddress3") & "br /">
<% If rsRobtest.Fields.Item("mlAddress4").Value)<>"" Then Responce.Write
Recordset("mlAddress4") & "br /">
<% If rsRobtest.Fields.Item("mlTown").Value)<>"" Then Responce.Write
Recordset("mlTown") & "br /">
| |
| Singularity.co.uk 2005-03-09, 6:19 pm |
| Alan
Try the code below:
<%
If rsRobtest.Fields.Item("mlAddress1").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlAddress1").Value & "<br>"
End If
If rsRobtest.Fields.Item("mlAddress2").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlAddress2").Value & "<br>"
End If
If rsRobtest.Fields.Item("mlAddress3").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlAddress3").Value & "<br>"
End If
If rsRobtest.Fields.Item("mlAddress4").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlAddress4").Value & "<br>"
End If
If rsRobtest.Fields.Item("mlTown").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlTown").Value & "<br>"
End If
%>
Although you may want to check for NULL values as well. Hope this helps.
Brendan
"AlanShaw" <webforumsuser@macromedia.com> wrote in message
news:d0mpur$253$1@forums.macromedia.com...
> Any ideas on how to make this work would be appreciated. It fails at the
'line
> break'
>
> <% If rsRobtest.Fields.Item("mlAddress1").Value)<>"" Then Responce.Write
> Recordset("mlAddress1") & "br /">
> <% If rsRobtest.Fields.Item("mlAddress2").Value)<>"" Then
Responce.Write
> Recordset("mlAddress2") & "br /">
> <% If rsRobtest.Fields.Item("mlAddress3").Value)<>"" Then
Responce.Write
> Recordset("mlAddress3") & "br /">
> <% If rsRobtest.Fields.Item("mlAddress4").Value)<>"" Then
Responce.Write
> Recordset("mlAddress4") & "br /">
> <% If rsRobtest.Fields.Item("mlTown").Value)<>"" Then Responce.Write
> Recordset("mlTown") & "br /">
>
| |
| AlanShaw 2005-03-09, 6:19 pm |
| Sorry everybody, I attached the wrong code, here is the correct code whick
fails at the line break.
<% If(rsRobtest.Fields.Item("mlAddress1").Value)<>"" Then Responce.write
(rsRobtest.Fields.Item("mlAddress1").Value) & "br /"%>
<% If(rsRobtest.Fields.Item("mlAddress2").Value)<>"" Then Responce.write
(rsRobtest.Fields.Item("mlAddress2").Value) & "br /"%>
<% If(rsRobtest.Fields.Item("mlAddress3").Value)<>"" Then Responce.write
(rsRobtest.Fields.Item("mlAddress3").Value) & "br /"%>
<% If(rsRobtest.Fields.Item("mlAddress4").Value)<>"" Then Responce.write
(rsRobtest.Fields.Item("mlAddress4").Value) & "br /"%>
<% If(rsRobtest.Fields.Item("mlTown").Value)<>"" Then Responce.write
(rsRobtest.Fields.Item("mlAddress4").Value) & "br /"%>
| |
| AlanShaw 2005-03-09, 6:19 pm |
| Thanks Bredan, there are no errors now, but also no results displayed, just an
empty table. My original query which I posted some time ago was this, and the
code that you have seen today is as far as we have got. Any more ideas would be
gratefully appreiciated. Hi, I'm having problems displaying UK postal
addresses of which the data is retrieved from MS Access. The problem occurs
when an address has fewer than 8 lines, I've tried a few ideas and nothing
seems to work. Firstly I created a table 8 rows x 2 columns so that the address
would display like so in the left hand column, (contact names, numbers, email
and website addresses go in the right hand column.) Roadhouse Rest Home
Supplies Unit 7 Cotswold Industrial Estate Primrose Hill Kings Langley WATFORD
Hertfordshire WD9 9QQ This is how I would like it displayed, and that is fine
all the time there are 8 lines in the address, but sometimes they are much
shorter and gaps appear like so; Border Rest Home 123 Any Street WOKING
Surrey GU99 9QQ So I then merged the left hand cells and restricted the width.
I then inserted the variable followed by a line break but the same thing
happened. I see now that the line break caused this. It's probably impossible
to restrict the width considering some company names are much shorter than
others. Yet if the width is unrestricted, the result with short names appear
like so: Border Rest Home 123 Any Street WOKING Surrey GU99 9QQ Does anybody
know a solution to my problem? Regards Alan
| |
| Jon Spivey 2005-03-09, 6:19 pm |
| Hi,
I hope there's a typo in this :-) Responce.write should be response.write.
<%
If rsRobtest("mlAddress1") <> "" Then Response.write rsRobtest(
"mlAddress1") & "<br>"
If rsRobtest("mlAddress2") <> "" Then Response.write
rsRobtest.("mlAddress2")& "<br>"
If rsRobtest("mlAddress3") <> "" Then Response.write
rsRobtest("mlAddress3") & "<br >"
' and so on
%>
Cheers,
Jon
"AlanShaw" <webforumsuser@macromedia.com> wrote in message
news:d0mr02$3sh$1@forums.macromedia.com...
> Sorry everybody, I attached the wrong code, here is the correct code whick
> fails at the line break.
>
> <% If(rsRobtest.Fields.Item("mlAddress1").Value)<>"" Then Responce.write
> (rsRobtest.Fields.Item("mlAddress1").Value) & "br /"%>
> <% If(rsRobtest.Fields.Item("mlAddress2").Value)<>"" Then Responce.write
> (rsRobtest.Fields.Item("mlAddress2").Value) & "br /"%>
> <% If(rsRobtest.Fields.Item("mlAddress3").Value)<>"" Then Responce.write
> (rsRobtest.Fields.Item("mlAddress3").Value) & "br /"%>
> <% If(rsRobtest.Fields.Item("mlAddress4").Value)<>"" Then Responce.write
> (rsRobtest.Fields.Item("mlAddress4").Value) & "br /"%>
> <% If(rsRobtest.Fields.Item("mlTown").Value)<>"" Then Responce.write
> (rsRobtest.Fields.Item("mlAddress4").Value) & "br /"%>
>
| |
| AlanShaw 2005-03-09, 11:17 pm |
| I've progressed a little with this but can anybody see why its showing no
results See http://www.cai.org.uk/test/test1.asp
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td height="34">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr class="sitemapheaders">
<td width="62%" valign="top">
<hr> </tr>
<tr class="sitemapheaders">
<td valign="top">
<%
If rsRobtest("mlAddress1")<>"" Then Response.Write rsRobtest.("mlAddress1") &
"<br>"
If rsRobtest("mlAddress2")<>"" Then Response.Write rsRobtest("mlAddress2") &
"<br>"
If rsRobtest("mlAddress3")<>"" Then Response.Write rsRobtest("mlAddress3") &
"<br>"
If rsRobtest("mlAddress4")<>"" Then Response.Write rsRobtest("mlAddress4") &
"<br>"
If rsRobtest("mlTown")<>"" Then Response.Write rsRobtest("mlTown") & "<br>"
%>
</tr>
<tr>
<td valign="top">
<hr></tr>
</table>
| |
| AlanShaw 2005-03-09, 11:17 pm |
| I've been and done it again, and posted the wrong bit of code, forget the above
and look at this.
<body>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td height="34">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr class="sitemapheaders">
<td width="62%" valign="top">
<hr> </tr>
<tr class="sitemapheaders">
<td valign="top">
<% If rsRobtest.Fields.Item("mlAddress1").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlAddress1").Value & "<br>" End If
If rsRobtest.Fields.Item("mlAddress2").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlAddress2").Value & "<br>" End If
If rsRobtest.Fields.Item("mlAddress3").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlAddress3").Value & "<br>" End If
If rsRobtest.Fields.Item("mlAddress4").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlAddress4").Value & "<br>" End If
If rsRobtest.Fields.Item("mlTown").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlTown").Value & "<br>" End If%>
</tr>
<tr>
<td valign="top">
<hr></tr>
</table>
</body>
| |
| Singularity.co.uk 2005-03-10, 7:19 am |
| Alan
Is there definitely data in relevant fields in the database?
If so, then what is the recordset code to retrieve the database record at
the top of the page?
Brendan
"AlanShaw" <webforumsuser@macromedia.com> wrote in message
news:d0o34g$ac9$1@forums.macromedia.com...
> I've been and done it again, and posted the wrong bit of code, forget the
above
> and look at this.
>
> <body>
> <table width="100%" border="1" cellspacing="2" cellpadding="2">
> <tr>
> <td height="34">
> <table width="100%" border="0" cellspacing="2" cellpadding="2">
> <tr class="sitemapheaders">
> <td width="62%" valign="top">
> <hr> </tr>
> <tr class="sitemapheaders">
> <td valign="top">
> <% If rsRobtest.Fields.Item("mlAddress1").Value<>"" Then
> Response.Write rsRobtest.Fields.Item("mlAddress1").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlAddress2").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlAddress2").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlAddress3").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlAddress3").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlAddress4").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlAddress4").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlTown").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlTown").Value & "<br>" End If%>
> </tr>
> <tr>
> <td valign="top">
> <hr></tr>
> </table>
> </body>
>
| |
| AlanShaw 2005-03-10, 11:18 pm |
| Hi Brendan It all come from one database and there is content in the selected
fields The complete code is attached and the current result can be seen
http://www.cai.org.uk/test/test1.asp Regards Alan
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ConCAIMembers.asp" -->
<%
Dim rsRobtest
Dim rsRobtest_numRows
Set rsRobtest = Server.CreateObject("ADODB.Recordset")
rsRobtest.ActiveConnection = MM_ConCAIMembers_STRING
rsRobtest.Source = "SELECT * FROM Table1"
rsRobtest.CursorType = 0
rsRobtest.CursorLocation = 2
rsRobtest.LockType = 1
rsRobtest.Open()
rsRobtest_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="600" border="1" cellspacing="2" cellpadding="2">
<tr>
<td><hr></td>
</tr>
<tr>
<td><% If rsRobtest.Fields.Item("mlAddress1").Value<>"" Then
Response.Write rsRobtest.Fields.Item("mlAddress1").Value & "<br>" End If
If rsRobtest.Fields.Item("mlAddress2").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlAddress2").Value & "<br>" End If
If rsRobtest.Fields.Item("mlAddress3").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlAddress3").Value & "<br>" End If
If rsRobtest.Fields.Item("mlAddress4").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlAddress4").Value & "<br>" End If
If rsRobtest.Fields.Item("mlTown").Value<>"" Then Response.Write
rsRobtest.Fields.Item("mlTown").Value & "<br>" End If %> </td>
</tr>
<tr>
<td><hr></td>
</tr>
</table>
</body>
</html>
<%
rsRobtest.Close()
Set rsRobtest = Nothing
%>
| |
| Singularity.co.uk 2005-03-11, 7:17 am |
| Alan
Try the code below:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ConCAIMembers.asp" -->
<%
Dim rsRobtest
Dim rsRobtest_numRows
Set rsRobtest = Server.CreateObject("ADODB.Recordset")
rsRobtest.ActiveConnection = MM_ConCAIMembers_STRING
rsRobtest.Source = "SELECT * FROM Table1"
rsRobtest.CursorType = 0
rsRobtest.CursorLocation = 2
rsRobtest.LockType = 1
rsRobtest.Open()
rsRobtest_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="600" border="1" cellspacing="2" cellpadding="2">
<tr>
<td><hr></td>
</tr>
<tr>
<td>
<%
Dim Add1, Add2, Add3, Add4, AddTown
Add1 = rsRobtest.Fields.Item("mlAddress1").Value
Add2 = rsRobtest.Fields.Item("mlAddress2").Value
Add3 = rsRobtest.Fields.Item("mlAddress3").Value
Add4 = rsRobtest.Fields.Item("mlAddress4").Value
AddTown = rsRobtest.Fields.Item("mlTown").Value
If NOT ISNULL(Add1) And Add1 <> "" Then
Response.Write Add1 & "<br>"
End If
If NOT ISNULL(Add2) And Add2 <> "" Then
Response.Write Add2 & "<br>"
End If
If NOT ISNULL(Add3) And Add3 <> "" Then
Response.Write Add3 & "<br>"
End If
If NOT ISNULL(Add4) And Add4 <> "" Then
Response.Write Add4 & "<br>"
End If
If NOT ISNULL(AddTown) And AddTown <> "" Then
Response.Write AddTown & "<br>"
End If
</td>
</tr>
<tr>
<td><hr></td>
</tr>
</table>
</body>
</html>
<%
rsRobtest.Close()
Set rsRobtest = Nothing
%>
"AlanShaw" <webforumsuser@macromedia.com> wrote in message
news:d0qifh$cjt$1@forums.macromedia.com...
> Hi Brendan It all come from one database and there is content in the
selected
> fields The complete code is attached and the current result can be seen
> http://www.cai.org.uk/test/test1.asp Regards Alan
>
> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
> <!--#include file="../Connections/ConCAIMembers.asp" -->
> <%
> Dim rsRobtest
> Dim rsRobtest_numRows
>
> Set rsRobtest = Server.CreateObject("ADODB.Recordset")
> rsRobtest.ActiveConnection = MM_ConCAIMembers_STRING
> rsRobtest.Source = "SELECT * FROM Table1"
> rsRobtest.CursorType = 0
> rsRobtest.CursorLocation = 2
> rsRobtest.LockType = 1
> rsRobtest.Open()
>
> rsRobtest_numRows = 0
> %>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body>
> <table width="600" border="1" cellspacing="2" cellpadding="2">
> <tr>
> <td><hr></td>
> </tr>
> <tr>
> <td><% If rsRobtest.Fields.Item("mlAddress1").Value<>"" Then
> Response.Write rsRobtest.Fields.Item("mlAddress1").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlAddress2").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlAddress2").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlAddress3").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlAddress3").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlAddress4").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlAddress4").Value & "<br>" End If
> If rsRobtest.Fields.Item("mlTown").Value<>"" Then Response.Write
> rsRobtest.Fields.Item("mlTown").Value & "<br>" End If %> </td>
> </tr>
> <tr>
> <td><hr></td>
> </tr>
> </table>
> </body>
> </html>
> <%
> rsRobtest.Close()
> Set rsRobtest = Nothing
> %>
>
| |
| AlanShaw 2005-03-11, 6:20 pm |
| Hi Brendan After I added a ?%>? at the end of the ?bit where it should be? it
works perfect, I?ve been searching for the answer to this problem since I first
posted it here on the 12th July 2004. I?m absolutely delighted with the result,
Thank you very very much. I?m not the cleverest of people when it comes to
website stuff, I?m about 10 millionth in the queue because I?m an aerial rigger
by trade, but if I?d had brought ?Sams, Learn SQL in 24 Hours? do you think I
would have cracked it? Where is a good starting point? Regards Alan
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |