<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nick Knoops</title>
    <description>The latest articles on DEV Community by Nick Knoops (@nickknoops_37).</description>
    <link>https://dev.to/nickknoops_37</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F523726%2Ffda63d86-6a33-42f7-b98e-6ed74f29a595.png</url>
      <title>DEV Community: Nick Knoops</title>
      <link>https://dev.to/nickknoops_37</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nickknoops_37"/>
    <language>en</language>
    <item>
      <title>Dynamic generated nested table</title>
      <dc:creator>Nick Knoops</dc:creator>
      <pubDate>Tue, 01 Dec 2020 14:20:11 +0000</pubDate>
      <link>https://dev.to/nickknoops_37/dynamic-generated-nested-table-5cd2</link>
      <guid>https://dev.to/nickknoops_37/dynamic-generated-nested-table-5cd2</guid>
      <description>&lt;p&gt;I'm stuck on this issue for a while now, and i can't figure out how to solve this. I have a feeling i'm rather close to solving this. But the final piece of the puzzle is missing.&lt;/p&gt;

&lt;p&gt;What i'm trying to do? I use the MPDF library to render an PDF based on a XML source file. I want to make use of the nested table functionality. And creating the table with static html and rendering it works like a charm. However, generating the same structure based on the data itself is giving me a headache. The DOM structure should be: &lt;a href="https://pastebin.com/zuQAykCB"&gt;https://pastebin.com/zuQAykCB&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '&amp;lt;table&amp;gt;&amp;lt;tbody&amp;gt;';
  foreach($orderConfArray as $orderConfLine ) :
    $orderConfEconData = isset($orderConfLine['EconData']) ? $orderConfLine['EconData'] : '';
    foreach($orderConfEconData as $key =&amp;gt; $value) :
        $x++;      

        if($x === 1 ) :

            echo '
            &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;blank col&amp;lt;/td&amp;gt;
            &amp;lt;td colspan="6"&amp;gt;
            &amp;lt;table cellspacing="2" class="inner" width="100%"&amp;gt;
            &amp;lt;tbody&amp;gt;';
        endif;

        echo '&amp;lt;tr&amp;gt;';
                echo '&amp;lt;td&amp;gt;';
                echo 'content';
                echo '&amp;lt;/td&amp;gt;';
        echo '&amp;lt;/tr&amp;gt;';

        if($x === 16 ) :
            echo '
            &amp;lt;/tbody&amp;gt;
            &amp;lt;/table&amp;gt;
            &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;';
        $x = 0;
        $y = 0;
        endif;
    endforeach;
 endforeach;
 echo '&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I get the following output &lt;a href="https://pastebin.com/GmVDKw7e"&gt;https://pastebin.com/GmVDKw7e&lt;/a&gt;, which is close. But not yet what i'm trying to accomplish. I need to do the following (I think) to get this working:&lt;/p&gt;

&lt;p&gt;Count the total number of items&lt;br&gt;
If the count reaches a certain number (on the nested table's TD), it should create a new TR within the nested table and continue from there.&lt;br&gt;
If we reach a certain number of TR's within the nested table. It should create a new TR with a nested table altogether.&lt;br&gt;
I can't wrap my head around this. Does anyone have a clue on how to fix this?&lt;/p&gt;

</description>
      <category>php</category>
      <category>xml</category>
      <category>loops</category>
      <category>table</category>
    </item>
  </channel>
</rss>
