Forums
This topic is locked
Displaying a TEXT field from mySql with IF statem.
Posted 03 Nov 2005 13:36:43
1
has voted
03 Nov 2005 13:36:43 Ole Wegard Utne posted:
I posted earlier today on a reply to this problem, but please dont shoot me for posting several places thus I'm having difficulties finding the answer on this problem.Here we go:
This code cant be displayed when I use IF. Nor when I place a "clean" record on the page without the replace function after the end if statement.
Here's the code I use:
<% if (rsClient.Fields.Item("compInfo".value) <>("" then %>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tblCont">
<tr align="left" valign="middle" bgcolor="#999966">
<th height="22" bgcolor="#999966"> <strong>HEADING</strong></th>
</tr>
<tr>
<td width="20%"><%= Replace(rsClient.Fields.Item("compInfo".Value, VbCrLf, "<BR>"%></td>
</tr>
</table>
<% end if %>
I use ie6sp2, mySQL
Totally lost here <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Any suggestions appreciated
-ole wegard
Replies
Replied 04 Nov 2005 01:54:37
04 Nov 2005 01:54:37 Ole Wegard Utne replied:
Thanks for your quick response, but I'm sad to inform you that it didn't work.
Actually the response.write is in fact doing the same thing as a = am I right?
I found some info about the topic at 4guysfromrolla (4guysfromrolla.com/ASPScripts/PrintFAQ.asp?FAQID=80).
Apparently I need to write a variable to trick/convince the record memofield to be presented more than once (as I can figure it out)
In my code I'm writing it two times. When I declare the statement to se if the field is emtpy or not, and when I present the record itself on the page. Equals two times..... But then again I'm no programmer. I guess I just have to conform with inserting another field (eks showCompInfo) 0/1 in my db and then evalueting to present the memo depending on the value of showCompInfo.
Unless you have another brilliant suggestion? I'm allways gratefull for help
Humblely yours,
Ole Wegard
Actually the response.write is in fact doing the same thing as a = am I right?
I found some info about the topic at 4guysfromrolla (4guysfromrolla.com/ASPScripts/PrintFAQ.asp?FAQID=80).
Apparently I need to write a variable to trick/convince the record memofield to be presented more than once (as I can figure it out)
In my code I'm writing it two times. When I declare the statement to se if the field is emtpy or not, and when I present the record itself on the page. Equals two times..... But then again I'm no programmer. I guess I just have to conform with inserting another field (eks showCompInfo) 0/1 in my db and then evalueting to present the memo depending on the value of showCompInfo.
Unless you have another brilliant suggestion? I'm allways gratefull for help
Humblely yours,
Ole Wegard
Replied 21 Nov 2005 05:40:18
21 Nov 2005 05:40:18 Louis L replied:
try this one, if it dont work post the error please.
<%
Function fixBreaks(strText)
strText = Replace(strText, Chr(13), "<br>"
strText = Replace(strText, VbCrLf, "<br>"
Response.Write strText
End Function
%>
<%
if (rsClient.Fields.Item("compInfo".value) <>("" then
compInfo = rsClient.Fields.Item("compInfo".Value 'if it fails on this line then there is no such field as compInfo in your db.
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tblCont">
<tr align="left" valign="middle" bgcolor="#999966">
<th height="22" bgcolor="#999966"> <strong>HEADING</strong></th>
</tr>
<tr>
<td width="20%"><%=fixBreaks(compInfo)%></td>
</tr>
</table>
<% end if %>
Edited by - greynoise on 21 Nov 2005 05:41:16
<%
Function fixBreaks(strText)
strText = Replace(strText, Chr(13), "<br>"
strText = Replace(strText, VbCrLf, "<br>"
Response.Write strText
End Function
%>
<%
if (rsClient.Fields.Item("compInfo".value) <>("" then
compInfo = rsClient.Fields.Item("compInfo".Value 'if it fails on this line then there is no such field as compInfo in your db.
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tblCont">
<tr align="left" valign="middle" bgcolor="#999966">
<th height="22" bgcolor="#999966"> <strong>HEADING</strong></th>
</tr>
<tr>
<td width="20%"><%=fixBreaks(compInfo)%></td>
</tr>
</table>
<% end if %>
Edited by - greynoise on 21 Nov 2005 05:41:16