Challenge
https://ampscript30.com/ampscript-challenge-day16/
To display dynamic content using For loop.
Solution
%%[
SET @fullname = Concat(FirstName, " ", LastName)
SET @rows = LookupRows("AMPscript - Day 16 Order Details", "OrderId", OrderId)
SET @rowcount = RowCount(@rows)
]%%
Hi %%=v(@fullname)=%%,
Thanks for your order! Good things are coming your way
%%[
IF @rowcount > 0 THEN
FOR @i =1 TO @rowcount DO
SET @row = Row(@rows, @i)
SET @productname = Field(@row, "ProductName")
SET @productdesc = Field(@row, "ProductDesc")
SET @productqty = Field(@row, "ProductQty")
SET @productprice = FormatNumber(Field(@row, "ProductPrice"), "C", "en-US")
]%%
%%=v(@productname)=%%: %%=v(@productdesc)=%% - %%=v(@productqty)=%% at %%=v(@productprice)=%%
%%[
NEXT @i
ELSE
RaiseError('No value found', true)
ENDIF]%%
If you have any questions, reply to this email or contact us at hello@nexttelecom.com
Best regards,
Next Telecom

Preview



Summary
Similar logic with the Day 15 challenge. After adding the error handler, MC will be able to display the error message and the email will not render for that particular subscriber as the process will be stopped.