Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ColdFusion Query Result

    How do I go about checking to see if a query result returned a blank field, when selecting more than one field (which means the recordcount wont work). Here's my query.

    <cfquery name="GetArtist" datasource="MySQL_Users">
    SELECT ArtistName,
    Song1,
    Song2,
    Song3
    FROM Artist_Info
    WHERE UserName = "#Session.UserName#"
    AND Password = "#Session.Password#"
    </cfquery>

    Now for example, lets say artist name is there, and song 1 is there. How can I find out if song2 and song3 are empty. I need to do this for a few reasons, but the main one now is for a comparison. If the artist query returns blank, cfoutput is "Register Artist" while if it returns a name, cfoutput is "Edit Artist".

  • #2
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You just need to do some simple checking using <CFif />

    If you're using <CFoutput /> with the query attribute, then it might be something like this:

    Code:
    <CFoutput query="GetArtists">
       <CFif song1 is "">... do something ...</CFif>
    </CFoutput>
    And then if you want to check outside a loop:

    <CFoutput query="GetArtists">

    Code:
    <CFif GetArtists.song1 is "">... do something ...</CFif>
    But based on the simple snippet you've shown alone, I feel like I could assume you've got such basics covered, so I wonder if you were unclear or I didn't understand something quite right.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •