|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
||||
|
||||
|
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) ![]() |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Nesting CFLOOPS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|