Here's how I'd approach this -- loop twice through the subscriber's events with the first loop qualifying the events with a matching event_name
and looping again to build the output string.
In the recommendation section, you can use the indexOf() function to determine if a person has attended a particular series of events or not and then output the content that's in line with your requirements.
%%[
set @debug = 1
/* pull email address from system string */
set @EmailAddress = AttributeValue("emailaddr")
set @firstName = AttributeValue("FirstName")
set @attendedEvents = LookupRows('event','Email_address', @EmailAddress)
set @rowCount = rowcount(@attendedEvents)
if @debug == 1 then
output(concat("<br>rowCount: ", @rowCount))
endif
set @attendedEventNames = ""
set @attendedEventIds = ""
set @qualifiedEventCount = 0
/* qualified event loop -- events with a webinar names match */
for @i = 1 TO @rowCount do
set @row = row(@attendedEvents,@i)
set @eventID = field(@row,'Event_ID')
set @event_name = Lookup("Webinar names", "event_name", "Event_ID", @eventID)
if @debug == 1 then
output(concat("<br>eventID: ", @eventID))
output(concat("<br>event_name: ", @rowCount))
endif
if not empty(@event_name) then
set @qualifiedEventCount = add(@qualifiedEventCount,1)
set @attendedEventNames = concat(@attendedEventNames, "|", @event_name)
set @attendedEventIds = concat(@attendedEventIds, "|", @eventId)
/* strip leading delimiter from first element */
if @qualifiedEventCount == 1 then
set @attendedEventNames = replace(@attendedEventNames,"|","")
set @attendedEventIds = replace(@attendedEventIds,"|","")
endif
endif
next @i
if @debug == 1 then
output(concat("<br>qualifiedEventCount: ", @qualifiedEventCount))
output(concat("<br>attendedEventNames: ", @attendedEventNames))
output(concat("<br>attendedEventIds: ", @attendedEventIds))
endif
if @qualifiedEventCount == 0 then
raiseError("No qualifed events for subscriber", 1) /* skip the send to this subscriber */
endif
set @attendedEventNamesOutput = ""
set @qualifiedEventNamesRowset = buildrowsetfromstring(@qualifiedEventNamesRowset,"|")
set @rowcount = rowCount(@qualifiedEventNamesRowset)
if @debug == 1 then
output(concat("<br>rowCount (2): ", @rowCount))
endif
/* qualified event output loop -- build a punctuated output string */
for @i = 1 to @rowcount do
set @row = row(@qualifiedEventNamesRowset, @i)
set @eventName = field(@row,1)
if @i == 1 then
set @attendedEventNamesOutput = @eventName
elseif @i == @qualifiedEventCount then
set @attendedEventNamesOutput = concat(@attendedEventNamesOutput, " and ", @eventName)
else
set @attendedEventNamesOutput = concat(@attendedEventNamesOutput, ", ", @eventName)
endif
next @i
]%%
Hello, %%=properCase(@firstName)=%%. Thanks for watching %%=v(@attendedEventNamesOutput)=%%.
<br><br>Here is more content you might like:
%%[ /* output content based on events attended */ ]%%
%%[ if indexOf(@attendedEventIds, "12345") > 0 and indexOf(@attendedEventIds, "23456") == 0 and indexOf(@attendedEventIds, "9876") == 0 then ]%%
%%[ /* attended 12345, but not 23456 and 9876 */ ]%%
<p>CONTENT HERE</p>
%%[ elseif indexOf(@attendedEventIds, "2345") == 0 and indexOf(@attendedEventIds, "789") == 0 then ]%%
%%[ /* attended 2345, but not 789 */ ]%%
<p>CONTENT HERE</p>
%%[ endif ]%%
Event
andWebinar names
, it would be helpful.