I have 2 tables to be rendered in my email based on conditions and loops. In case of even number of tables, everything is properly fine. However, in case of odd number of tables, the 1st table in the row is shifted to right. Every row should contain 2 tables. For eg: In case of 3 tables, 1st row of tables render properly, but the next table gets distorted. However, in case of 4 tables, the 3rd table is properly fine.
%%[ for @counter = 1 to @count do IF MOD(@counter,2) != "0" THEN TreatAsContent( Concat('%','%[SET @row1= Row(@package',@counter, ',', @countername,')]%', '%' ) ) TreatAsContent( Concat('%','%[SET @row2= Row(@package',@counter, ',', @counterdate,')]%', '%' ) ) SET @name1 = Field(@row1,1) SET @date1 = Field(@row2,1) ]%% <tr>
<td class="Zero" style="padding: 30px 30px 0px 0px;" width="250px">
<table cellpadding="25" cellspacing="0" class="container" style="border-collapse: collapse; display:flex;" width="250px">
<tr>
<td align="left" style="background:#ffffff; border: 1px solid #EAEAEA;color:#4a4a4a;font-size:16px;line-height:24px;font-family:Helvetica,Arial,sans-serif;" valign="top" width="250px">
<span><b>%%=V(@name1)=%%</b><br>
Nächste Abrechung: %%=V(@date1)=%%</span></td></tr></table><img alt="" src="http://image.mailing.sky.de/lib/fe38117075640474721472/m/1/93644f5f-ccc7-4260-bff0-1b2ff54c8808.png" style="width: 100%; height: auto; padding: 0px; vertical-align: top;" width="245"></td>
<td class="Zero" style="padding: 30px 30px 0px 0px;" width="250px">
%%[IF @counter < @count THEN SET @dummycounter = ADD(@counter,"1") IF CONCAT('@flag',@dummycounter) != "0" THEN TreatAsContent( Concat('%','%[SET @row4= Row(@package',@dummycounter, ',', @countername,')]%', '%' ) ) TreatAsContent( Concat('%','%[SET @row5= Row(@package',@dummycounter, ',', @counterdate,')]%', '%' ) ) SET @name2 = Field(@row4,1) SET @date2 = Field(@row5,1) IF @name2 != "" THEN]%%<table cellpadding="25" cellspacing="0" class="container" style="background:#fff; border-collapse: collapse; display:flex;" width="250px">
<tr>
<td align="Left" style="background:#ffffff; border: 1px solid #EAEAEA;color:#4a4a4a;font-size:16px;line-height:24px;font-family:Helvetica,Arial,sans-serif;" valign="top" width="250px">
<span><b>%%=V(@name2)=%%</b><br>
Nächste Abrechung: %%=V(@date2)=%%</span></td></tr></table> <img alt="" src="http://image.mailing.sky.de/lib/fe38117075640474721472/m/1/93644f5f-ccc7-4260-bff0-1b2ff54c8808.png" style="width: 100%; height: auto; padding: 0px;vertical-align: top;" width="245">%%[ENDIF ENDIF ENDIF]%%</td></tr></table>%%[ ENDIF next @counter ]%%
<td align="left" valign="top">
to all <td> tags... And also addalign="center"
to all <table> tags.<td>
tag ....... For example the<img
tag lying outside table tag only!... also place the conditional AMPscript code BEFORE<td>
tag, not after!... hope this helps.