Skip to main content
Inspiring
March 31, 2008
Question

can't get loops running correctly

  • March 31, 2008
  • 3 replies
  • 576 views
Hi there,

I've made a page to automatically send users an email with updates in.

However the outputs are currently wrong and it is sending updates to the wrong people.

The search is made by matching the users location to a sports club location. Currently they are not being matched to the correct user e.g. John who lives in London is being sent updates from clubs in Yorkshire...

Can anyone see where i've gone wrong?

Cheers

James
    This topic has been closed for replies.

    3 replies

    RookOrnAuthor
    Inspiring
    March 31, 2008

    Inspiring
    March 31, 2008
    combine your 2 queries into 1 JOIN query and use that in the query
    attribute of cfmail tag.

    currently, since you 2nd query is not inside a cfoutput of the 1st
    query, your #user.defaultsport# always evaluates to the value in the
    first row of your 1st query only.

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    RookOrnAuthor
    Inspiring
    March 31, 2008
    thanks for your replies guys.

    It now outputs correctly. However, i just need to twig it so that all the clubs are outputted under 1 name. i.e. it doesnt send an email for each find, just 1 email with all the finds in...

    Currently the code will output:

    John West Yorkshire The Destroyers
    John West Yorkshire Luminos
    John West Yorkshire Royal Parkers
    John West Yorkshire Hyde Park FC
    John West Yorkshire Luminos FC
    John West Yorkshire The Destroyers FC
    John West Yorkshire Glow worms

    Any ideas how i can do this? I've taken the cfmail out just to get it working first.

    Cheers
    March 31, 2008
    Hi,

    Well, you are using LIKE in your SQL. This may be matching others things than what you want. Have you tried hard coding some values and seeing what you get?

    Oh and, you shouldn't loop the CFMAIL tag itself. If you want to use query results with this, the CFMAIL tag comes with a QUERY attribute...use that instead. Although, in saying that, CFLOOP can be better if you are intending to send a huge amount (5k), but that's another story.

    Hope this helps,
    Mikey.