HighDots Forums  

Converting DB Number Values to Predefined Text

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Converting DB Number Values to Predefined Text in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tical
 
Posts: n/a

Default Converting DB Number Values to Predefined Text - 07-03-2004 , 02:25 PM






I am trying to convert a list of different database values (numbers) to a value
(text) specified by a page.

I have 2 tables, the master table holds the category Id and Name, the related
secondary table holds just the Id.
I need the page to convert the values from a set list.

For example, if the recordset returns the value 2, the page would display the
text "Category Value 02"
I need to create this effect with 8 different possible values from the
database.

I have partially created this effect by editing one of RobGT.com extensions,
but found it a messy solution that had additional unwanted effects.
The code i have created is as follows...

<%
If (Recordset1.Fields.Item("ID").Value) <> "1" Then%>
<%=Replace(Recordset1.Fields.Item("ID").Value,chr( 13),"<br>")%>
<% Else
Response.Write ("Category Value 01")
End If %>
<%
If (Recordset1.Fields.Item("ID").Value) <> "2" Then%>
<%=Replace(Recordset1.Fields.Item("ID").Value,chr( 13),"<br>")%>
<% Else
Response.Write ("Category Value 02")
End If %>
<%
If (Recordset1.Fields.Item("ID").Value) <> "3" Then%>
<%=Replace(Recordset1.Fields.Item("ID").Value,chr( 13),"<br>")%>
<% Else
Response.Write ("Category Value 03")
End If %>

Anyone any ideas on solving this problem?
Im using ASP VB
TIA
Rob


Reply With Quote
  #2  
Old   
Jeff North
 
Posts: n/a

Default Re: Converting DB Number Values to Predefined Text - 07-03-2004 , 03:55 PM






On Sat, 3 Jul 2004 18:25:00 +0000 (UTC), in macromedia.dreamweaver
"Tical" <webforumsuser (AT) macromedia (DOT) com> wrote:

Quote:
| I am trying to convert a list of different database values (numbers) to a value
| (text) specified by a page.
|
| I have 2 tables, the master table holds the category Id and Name, the related
| secondary table holds just the Id.
| I need the page to convert the values from a set list.
|
| For example, if the recordset returns the value 2, the page would display the
| text "Category Value 02"
| I need to create this effect with 8 different possible values from the
| database.
|
| I have partially created this effect by editing one of RobGT.com extensions,
| but found it a messy solution that had additional unwanted effects.
| The code i have created is as follows...
|
| <%
| If (Recordset1.Fields.Item("ID").Value) <> "1" Then%
| <%=Replace(Recordset1.Fields.Item("ID").Value,chr( 13),"<br>")%
| <% Else
| Response.Write ("Category Value 01")
| End If %
| <%
| If (Recordset1.Fields.Item("ID").Value) <> "2" Then%
| <%=Replace(Recordset1.Fields.Item("ID").Value,chr( 13),"<br>")%
| <% Else
| Response.Write ("Category Value 02")
| End If %
| <%
| If (Recordset1.Fields.Item("ID").Value) <> "3" Then%
| <%=Replace(Recordset1.Fields.Item("ID").Value,chr( 13),"<br>")%
| <% Else
| Response.Write ("Category Value 03")
| End If %
|
| Anyone any ideas on solving this problem?
| Im using ASP VB
| TIA
| Rob
In your sql statement:
(mysql)
select *, concat('Category Value ',format(id,'##')) as strID from
table

Access
select *, 'Category Value ' + format(id,'##') as strID from table

Display value:
<%=Recordset1.Fields.Item("strID").value%>


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.