Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfmail and looping ???

Status
Not open for further replies.

kuolung

Programmer
Sep 2, 1999
51
US
I'm just starting to learn CF, and i have this project : send out email to each student with information on each of the class they are taking, each student can and will have more than 1 class.

so far here's what i have:

<cfquery name=&quot;email_list&quot; datasource=&quot;webcf&quot;>
select email, name
from email_list
</cfquery>

<cfloop query=&quot;email_list&quot;>

<cfquery name=&quot;class_info&quot; datasource=&quot;webcf&quot;>
select distinct a.email, a.class, b.time, b.location
from email_list a, class_info b
where a.email_address = '#email_address#'
</cfquery>

<!C-- <cfmail
to=&quot;#email_list.email#&quot;
from=&quot;Register Office&quot;
subject=&quot;student and class info&quot;
server=&quot;#smtp_server#&quot;>

Class: #class_info.class#
Time: #class_info.time#
Location: #class_info.location#

</cfmail>

</cfloop>

i ran a test for this one, it only sends 1 class info. while the student has 4 class registered. I would like to have on email info. of all 4 class:


Class: MATH101
time: TR
location: JC101

Class: ENG101
time: MWF
location: ST300
...

and so on.


PLEASE HELP!!!


 
you miss one loop !!!

<cfloop query=&quot;email_list&quot;> // for each name in the email list, we're going to :
<cfquery name=&quot;class_info&quot; datasource=&quot;webcf&quot;>...</cfquery> // get its classes ....

<!C-- <cfmail ...
Class: #class_info.class#
Time: #class_info.time#
</cfmail>
// and email just the first line !!!!!
</cfloop>

see ? if you want ALL the classes add a loop here :

<!C-- <cfmail ...>

<cfloop query = class_info ...>
Class: #class_info.class#
Time: #class_info.time#
Location: #class_info.location#
</cfloop>

</cfmail>


let me know if it doesn't solve your problem (bt it definitly should !)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top