Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


replace function in array

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,1217
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> replace function in array
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 replace function in array - 8/5/2004 6:31:14 PM   
  sr_aneesh

 

Posts: 2
Score: 0
Joined: 8/5/2004
From:
Status: offline
i have two tables color and cloths.

The Data in color Table are :

id Color
1 Red
2 Orange
3 Yellow
4 pink
5 white


Data in Cloths table are like

Clothid Size Color Cost
1 XL 1,4,3 450
2 L 2,5 650
3 X 2,3,5 200


The color field in Cloths table is the id in the color table
that means Clothid 1 has a XL size cloths of Red,Pink,Yellow (1,4,3)

now i want when i view the data, instead of the colorids in the cloths table the colorname should appear that means insaed of 1,4,3 i want Red,Pink,Yellow.

i think the best way is through function

what function should i write to do so.


i wrote something like this which gave error. pls rectify. what are the other methods to come up with the said result.
<%
sqlcolor="select * from color"
set rscolor=conn.Execute(sqlcolor)
sqlt="select id,size,color from cloth"
set rs=conn.Execute(sqlt)
%>

Function showcolor(i,w)
t=split(i,",")
for u= 0 to ubound(t)
for s =0 to ubound(w)
if t(u)=w(s) then
replace(t(u),w(1))
end if
next
next
End Function


<%showcolor(rs(2),rscolor)%>
 
 
Post #: 1
 
 Re: replace function in array - 8/17/2004 9:57:13 PM   
  Matt

 

Posts: 30
Score: 0
Joined: 8/17/2004
From: United Kingdom
Status: offline
The answer my friend is to work smarter not harder.

SELECT * FROM [color table] INNER JOIN [Cloths] ON [color table].id = [Cloths].[color];

This SQL will grab both tables and you can treat it like one big table!

So now you can output rs.fields("color").vlaue rather than spend a lot of processor time with functions that are slower than SQL.

I hope that's clear enough and helps.

(in reply to sr_aneesh)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> replace function in array Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts