473,408 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

pulling stuff from comma-delimited field

I have a page where I allow the user to select one or more names of
employees to send an email to, which is sent automatically when the form is
submitted. I have a field called EmailSentTo, and if you sent it to Joe
Smith, then it stores the employee's number, 200, which is the PK of the
Employee table.

And there is, of course, another page which displays all the information
from that form I just submitted, so I want to display this new thing I
added, the name of the person I sent an email to. So far, no problem.

The thing gets complicated when I choose to send the email to more than one
person. In that case, I select Joe Smith and Mary Jones, and it enters
"200,100" into the field. A comma-delimited set of empoloyee IDs.

I realize that in order to display this, I would need some sort of loop, but
I'm not sure about how to do this. I can do a loop which pulls different
records from a table, but this is pulling several things from one field of
one record. Anyone got any sample code?

(BTW, I know that this is essentially a one-to-many, and I should simply
break it down to another table, but I was trying to avoid that. But I will
if that's the best thing to do)
Jul 19 '05 #1
3 3378
I am not sure I understand you correctly,

but you can use the split() function to split a string "100,200, 300" into
an array .
Or if you use that in a select statement use can use
select * from table where EmployeeID in (100,200,300)
then you can loop through that...

HTH

"middletree" <mi********@htomail.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
I have a page where I allow the user to select one or more names of
employees to send an email to, which is sent automatically when the form is submitted. I have a field called EmailSentTo, and if you sent it to Joe
Smith, then it stores the employee's number, 200, which is the PK of the
Employee table.

And there is, of course, another page which displays all the information
from that form I just submitted, so I want to display this new thing I
added, the name of the person I sent an email to. So far, no problem.

The thing gets complicated when I choose to send the email to more than one person. In that case, I select Joe Smith and Mary Jones, and it enters
"200,100" into the field. A comma-delimited set of empoloyee IDs.

I realize that in order to display this, I would need some sort of loop, but I'm not sure about how to do this. I can do a loop which pulls different
records from a table, but this is pulling several things from one field of
one record. Anyone got any sample code?

(BTW, I know that this is essentially a one-to-many, and I should simply
break it down to another table, but I was trying to avoid that. But I will
if that's the best thing to do)

Jul 19 '05 #2
sIDlist = "200,100"
aIDarray = split(sIDlist, ",")
for i = 0 to ubound(aIDarray)
nThisID = aIDarray(i)
DoSomethingWith(nThisID)
next

or...

sIDlist = "200,100"
sSQL = "Select field1, field2 from table1 where ID in (" & sIDlist & ")"
set rs = conn.Execute(sSQL)
do until rs.EOF
DoWhateverWith(rs("field1"))
rs.MoveNext
loop

"middletree" <mi********@htomail.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
I have a page where I allow the user to select one or more names of
employees to send an email to, which is sent automatically when the form is submitted. I have a field called EmailSentTo, and if you sent it to Joe Smith, then it stores the employee's number, 200, which is the PK of the Employee table.

And there is, of course, another page which displays all the information from that form I just submitted, so I want to display this new thing I
added, the name of the person I sent an email to. So far, no problem.

The thing gets complicated when I choose to send the email to more than one person. In that case, I select Joe Smith and Mary Jones, and it enters
"200,100" into the field. A comma-delimited set of empoloyee IDs.

I realize that in order to display this, I would need some sort of loop, but I'm not sure about how to do this. I can do a loop which pulls different records from a table, but this is pulling several things from one field of one record. Anyone got any sample code?

(BTW, I know that this is essentially a one-to-many, and I should simply break it down to another table, but I was trying to avoid that. But I will if that's the best thing to do)

Jul 19 '05 #3
Don't really know much about arrays, but I think I can work with this.
Thanks.
"Kris Eiben" <ei*********************@yahoo.com> wrote in message
news:es**************@TK2MSFTNGP12.phx.gbl...
sIDlist = "200,100"
aIDarray = split(sIDlist, ",")
for i = 0 to ubound(aIDarray)
nThisID = aIDarray(i)
DoSomethingWith(nThisID)
next

or...

sIDlist = "200,100"
sSQL = "Select field1, field2 from table1 where ID in (" & sIDlist & ")"
set rs = conn.Execute(sSQL)
do until rs.EOF
DoWhateverWith(rs("field1"))
rs.MoveNext
loop

"middletree" <mi********@htomail.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
I have a page where I allow the user to select one or more names of
employees to send an email to, which is sent automatically when the

form is
submitted. I have a field called EmailSentTo, and if you sent it to

Joe
Smith, then it stores the employee's number, 200, which is the PK of

the
Employee table.

And there is, of course, another page which displays all the

information
from that form I just submitted, so I want to display this new thing I
added, the name of the person I sent an email to. So far, no problem.

The thing gets complicated when I choose to send the email to more

than one
person. In that case, I select Joe Smith and Mary Jones, and it enters
"200,100" into the field. A comma-delimited set of empoloyee IDs.

I realize that in order to display this, I would need some sort of

loop, but
I'm not sure about how to do this. I can do a loop which pulls

different
records from a table, but this is pulling several things from one

field of
one record. Anyone got any sample code?

(BTW, I know that this is essentially a one-to-many, and I should

simply
break it down to another table, but I was trying to avoid that. But I

will
if that's the best thing to do)


Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Alberto Vera | last post by:
Hello: I have the next structure: How Can I make it using Python? How Can I update the value of 6?
1
by: David Fraser | last post by:
I used this when trying to retrieve the McMillan site. Others might find it useful... David #!/usr/bin/env python import urlparse import urllib2 import os
11
by: Shawn Odekirk | last post by:
Some code I have inherited contains a macro like the following: #define setState(state, newstate) \ (state >= newstate) ? \ (fprintf(stderr, "Illegal...
3
by: hourlie | last post by:
I have a string... abcdefghijklmnop I know the 'abcdefg' and i know the 'jklmnop', but I dont know the >hi<. How do I assign this >hi< to a string so that I can play with it later?
10
by: Jeff | last post by:
Hey gang. i have a code that i will list. when varM = 8 or 16, the script works fine, and pulls the top 8 or top 16, but if it =32 or 64, it is only pulling the top 17 records from the DB. db is...
4
by: sklett | last post by:
given one of these two string: ProtocolRecord(0, 100, 100, arZeroMax , 1, 0, SKIP,0), ProtocolRecord(0, 100, 100, arSetSet , 4, 0, DJMPNZSTOP, (void *) &Protocol_TD) I want to pull all the...
2
by: MS | last post by:
I am new to PHP and MySql. What I would like to do is have my PHP page pull the name of an image (jpeg, bmp, etc.) out of MySQL and display image from another directory. I don't want the actual...
15
by: Lighter | last post by:
In 5.3.3.4 of the standard, the standard provides that "The lvalue-to- rvalue(4.1), array-to-pointer(4.2),and function-to-pointer(4.3) standard conversions are not applied to the operand of...
5
by: Jim in Arizona | last post by:
I built a webpage using vb.net (.net 2.0) that creates a form letter. This letter pulls data from a database. Although I populate the address with the person's full name, which comes from the name...
3
by: Donkeyoz | last post by:
Hi all, Trying to do something fairly basic but am getting caught up on it. I am trying to extract text from a .txt file into an array line by line and then dissect that line into various parts,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.