title: datatables child tables populated with PHP data
body: <p>I've been trying to sort out the best way to get DataTables' <a href="http://datatables.net/release-datatables/examples/api/row_details.html" rel="noreferrer">child rows,</a> to work with my data. There are several posts here on it, but none of those mention my issue specifically.</p>
  
  <p><strong>My situation:</strong></p>
  
  <p>Prior to wanting to add expandable rows, all of my data was brought into the page via PHP, connecting directly to my MySQL database and populating a table that is wrapped in the DataTables <code>$(document).ready</code> function.  Loading DataTables was simple, and it worked fine.  <strong>However</strong>, I don't see any way for me, using the PHP data, to add expandable child rows, as the data must be (as far as I can tell) added after the initial generation of the table, as shown here in their demo file:</p>
  
  <pre><code> $('#example tbody').on('click', 'td.details-control', function () {
  
  
          var tr = $(this).closest('tr');       
          var row = table.row( tr );
          console.log(row);
  
          if ( row.child.isShown() ) {
              // This row is already open - close it
              row.child.hide();
              tr.removeClass('shown');
          }
          else {
              // Open this row
              row.child( format(row.data()) ).show();
              tr.addClass('shown');
          }
  
  
  
      });
  
  function format ( d ) {
      // `d` is the original data object for the row
      return '&lt;table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;"&gt;'+
          '&lt;tr&gt;'+
              '&lt;td&gt;Full name:&lt;/td&gt;'+
              '&lt;td&gt;hi&lt;/td&gt;'+
          '&lt;/tr&gt;'+
          '&lt;tr&gt;'+
              '&lt;td&gt;Extension number:&lt;/td&gt;'+
              '&lt;td&gt;12345&lt;/td&gt;'+
          '&lt;/tr&gt;'+
          '&lt;tr&gt;'+
              '&lt;td&gt;Extra info:&lt;/td&gt;'+
              '&lt;td&gt;And any further details here (images etc)...&lt;/td&gt;'+
          '&lt;/tr&gt;'+
      '&lt;/table&gt;';
  }
  </code></pre>
  
  <p>even this code WORKS, technically.  When I click on a cell, it expands, showing this newly-created table underneath - but I don't know of any way to populate that with the php data that I want to, (instead of the generic data here...), as the PHP code was generated from the server prior to the JavaScript code running, etc etc. </p>
  
  <p><strong>What I've tried:</strong></p>
  
  <p>I read up <a href="https://www.datatables.net/examples/data_sources/server_side.html" rel="noreferrer">here</a> on DataTables' server-side processing, and modified the script they have on the website, but when I ran the php file for the first time, I was missing <code>ssp.class.php</code>, so I downloaded the latest version of DataTables, and then called it with this:</p>
  
  <pre><code>require( '../../plugins/jqueryDataTables/DataTables-1.10.7/examples/server_side/scripts/ssp.class.php' );
  </code></pre>
  
  <p>However, now, I get this error:    </p>
  
  <pre><code>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 57 bytes) in C:\xampp\htdocs\plugins\jqueryDataTables\scripts\ssp.class.php on line 433
  </code></pre>
  
  <p>line 433 reads: <code>return $stmt-&gt;fetchAll();</code></p>
  
  <p>I have no idea what to do or why I can't get the script to work correctly, but after hours and hours on DataTables' website, I'm frustrated.  Any help on my situation would be great, or if I'm going about this all wrong in the first place, that would be nice to hear too!</p>