...

View Full Version : ColdFusion Query Result



solow
11-08-2004, 09:21 PM
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".

]|V|[agnus
11-09-2004, 04:03 PM
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:



<CFoutput query="GetArtists">
<CFif song1 is "">... do something ...</CFif>
</CFoutput>


And then if you want to check outside a loop:

<CFoutput query="GetArtists">



<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum