Cancel Email Sending (or processing) if Recordset is Blank?
I have the code below which works great to send an email when a new record has been added to the tickets table. (email code is not listed)
- The table column called "sent_email" starts with a default of 0
------------------------------------------
<cfquery name="rsSendEmail" datasource="loc">
SELECT tickets.ticketID, tickets.sent_email, tblusers.username, tblusers.username AS OwnName, tickets.ticket, tickets.original_date, tickets.work_date, tickets.priority, tickets.type, tickets.started, tickets.name, tickets.caller, tickets.contact, tickets.contact_phone, tickets.county, tickets.place, tickets.location, tickets.work_type, tickets.extent, tickets.remarks, tblusers.email, tblusers.firstName AS fn, tblusers.lastName, tblstatus.stDesc, tickets.street
FROM tblstatus RIGHT OUTER JOIN tickets ON tblstatus.stID = tickets.statusID LEFT OUTER JOIN tblusers ON tblusers.ID = tickets.ownerID
WHERE tickets.sent_email = "0"
LIMIT 1
</cfquery>
-----------------------------------------
- Once the email goes out, I run this code to update "sent_email" to a 1
-----------------------------------------
<cfquery name="rsSetSentFlag" datasource="loc">
UPDATE tickets
SET tickets.sent_email = "1"
WHERE tickets.sent_email = "0"
LIMIT 1
</cfquery>
------------------------------------------
I get the first email correctly, but then I keep getting emails with no data, that are blank?
I think I need to "Stop Processing" the rest of the page if the Select Query returns no records.
I tried to add this code below after the query, but it stops at the <cfabort line..
<cfif rsSendEmail.recordCount NEQ 0>
<cfabort showerror="">
<!--- Processing is stopped, --->
<!--- and subsequent operations are not carried out.--->
</cfif>
