ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 12th, 2005, 05:04 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
Arrow Nesting CFLOOPS

still on that dumb dating site.

Ok i made an internal mail system for our lovebirds, when a user "checks his mail" he sees a cfloop of mail sent to his Username he even sees the Username of the person who sent it, but now i have to put in there the photo of the person who sent it. How?

I dont have the name of the pic in that same table since the person can edit the pic and hence change the name of the photo. So the pic is only in the CLIENT table and the email is in the EMAIL table. So how do i get a cfloop to show the email from one table and the photo of another table conjointly. Ive tried this but i know its wrong. I just cant grasp the logic on this one.

Code:
<CFQUERY NAME="Emails" DATASOURCE="#Datasource#">
SELECT * FROM Email
WHERE To = '#ClientUsername#'
</CFQUERY>

<CFQUERY NAME="Pics" DATASOURCE="#Datasource#">
SELECT Picture, Username
FROM Client
</CFQUERY>

<CFQUERY NAME="Joiner" DBTYPE="query">
SELECT *
FROM Emails, Pics
WHERE Pics.Username = '#Emails.eFrom#'
</CFQUERY>


then i cfloop

Code:
 <cfloop query="Emails" startrow="#URL.StartRow#" endrow="#EndRow#">
guys name town date

<cfloop query="Pics" startrow="#URL.StartRow#" endrow="#EndRow#">				
<img src="the picture">
</CFLOOP>											
</CFLOOP>				


I know this is wrong the internal loop displays only 1 pic on all rows of email

Just need a nudge in the right direction of the logic behind this endeavor. thx

Reply With Quote
  #2  
Old April 12th, 2005, 05:34 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
Thumbs up

AWWWW YEAAAHHHHHH *Bad Word of your choice here*!!!!!!
Got that *another bad word*!!!!

Truly easy heres how to do it.

You got to put the 2nd query (the 2nd table in my case the one holding the picture) inside of the 1st loop then underneath you put the 2nd loop. BEHOLD.

Code:
<--! first query-->

<CFQUERY NAME="Email" DATASOURCE="#Datasource#">
SELECT *
FROM Email
WHERE Username = '#Email.From#'
</CFQUERY>


<--! first loop-->
<CFLOOP query="Email">


<--! 2ndquery-->
<CFQUERY NAME="Pics" DATASOURCE="#Datasource#">
SELECT pic, Username
FROM Client
WHERE Username = '#Email.From#'
</CFQUERY>
 

<--! 2nd loop-->                   
<cfloop query="Pics">
					
<img src="Picture here">

</cfloop>
</CFLOOP>



Yeah yeah i know this was supposed to be a no-brainer but it wasnt anywhere in this forum so

-Alas (still Tha Man)

Reply With Quote
  #3  
Old April 12th, 2005, 07:29 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
Is there a reason why you don't just do a JOIN on these two tables?

<CFQUERY NAME="EmailWithPics" DATASOURCE="#Datasource#">
e.to, e.from, e.subject, c.pic
from email e, client c
where c.username = e.from
and e.username = '#ClientUsername#'
</CFQUERY>

I am assuming the use of ClientUserName as the current user's user name but you can use whatever identifier you have that exists in the email table for the current user. I'm also assuming the names of the columns in the email table. In general you want to always avoid using "select *" as it is less clear and also has much more chance for pulling back columns that you might not use.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Last edited by kiteless : April 12th, 2005 at 07:34 PM.

Reply With Quote
  #4  
Old April 13th, 2005, 10:35 AM
Bastion Bastion is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 181 Bastion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 25 m 11 sec
Reputation Power: 5
I'm just wondering why don't you set up a photo naming convention? If each dater has a unique ID, then couldn't you call their photo ID534-lastname or lastname-534?

In theory, you would solve the photo deletion because the new photo would just write over the old one and it would allow you to construct the image name from the interested party's name and ID.

Then again, not seeing your app and not knowing how you are constructing things, this may not work.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Nesting CFLOOPS


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT