title: PHP Keeps Duplicating Table Elements in WordPress Theme
body: <p>I'm working on this <a href="http://testbuzz.illinimedia.com" rel="nofollow noreferrer">test site</a>, which is a WordPress website (using version 5.5) and using the <a href="http://www.woothemes.com/products/canvas/" rel="nofollow noreferrer">Canvas WooTheme</a>. The front page of it is supposed to display today's calendar events, which are provided by the WordPress plugin, <a href="http://wordpress.org/extend/plugins/events-manager/" rel="nofollow noreferrer">Events Manager</a>.</p>
  
  <p>What I would like for them to do is display, such as this <a href="http://testbuzz.illinimedia.com/events/2012-12-22" rel="nofollow noreferrer">events page</a> (and the screenshot below - seen in <a href="https://docs.google.com/open?id=0B2UC67NQiW2yYjBQd213OVE4ZHc" rel="nofollow noreferrer">this screenshot</a>), does. Instead, the code below somehow has the rest of the template (including the sidebar) sucked into the table, continuing to duplicate table rows and columns into itself (as seen from <a href="https://docs.google.com/open?id=0B2UC67NQiW2yc3hzdDJla1dKeUk" rel="nofollow noreferrer">this screenshot</a>).</p>
  
  <p>The code it shoots out into Firebug is the following:</p>
  
  <pre><code>&lt;table cellspacing="0" cellpadding="0" id="current-events"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="startdate_cost_td"&gt;
        &lt;span class="start_time"&gt;&lt;table cellspacing="0" cellpadding="0" id="current-events"&gt;&lt;tbody&gt;&lt;tr&gt;
          &lt;td class="startdate_cost_td"&gt;
                  &lt;span class="start_time"&gt;12:00 AM&lt;/span&gt;&lt;br&gt;
              &lt;span class="cost"&gt;Free&lt;/span&gt;
          &lt;/td&gt;
          &lt;td class="event_image"&gt; &lt;img src="../../../wp-includes/images/default_img.jpg"&gt;&lt;/td&gt;
          &lt;td class="event_title"&gt;Sex Addicts Anonymous meeting&lt;br&gt;
              &lt;i&gt;&lt;span class="location_name"&gt;@ No location listed&lt;/span&gt;&lt;/i&gt;
              &lt;div id="read_more_wrapper"&gt;
              &lt;img src="../../../wp-includes/images/little_pink_arrow.jpg"&gt;&lt;a class="pink_link" href="http://testbuzz.illinimedia.com/events/sex-addicts-anonymous-meeting-90"&gt;READ MORE&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  
  &lt;!--12:00 AM&lt;/span&gt;&lt;br/&gt;&lt;span class='cost'&gt;Free&lt;/span&gt;&lt;/td&gt;&lt;td class='event_image'&gt;&lt;img src='../../../wp-includes/images/default_img.jpg' /&gt;&lt;/td&gt;&lt;td class='event_title'&gt;&lt;a href="http://testbuzz.illinimedia.com/events/sex-addicts-anonymous-meeting-90" title="Sex Addicts Anonymous meeting"&gt;Sex Addicts Anonymous meeting&lt;/a&gt;&lt;br/&gt;&lt;i&gt;&lt;span class='location_name'&gt;@No location listed&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;Mind, body, &amp;amp; spirit&lt;div id='read_more_wrapper'&gt;&lt;img src='../../../wp-includes/images/little_pink_arrow.jpg' /&gt;&lt;a href='http://testbuzz.illinimedia.com/events/sex-addicts-anonymous-meeting-90' class='pink_link'&gt;READ MORE&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/div&gt;&lt;tr&gt;&lt;td class='startdate_cost_td'&gt;
        &lt;span  class='start_time'&gt;--&gt;
  &lt;tr&gt;
          &lt;td class="startdate_cost_td"&gt;
                  &lt;span class="start_time"&gt;8:30 AM&lt;/span&gt;&lt;br&gt;
              &lt;span class="cost"&gt;Free&lt;/span&gt;
          &lt;/td&gt;
          &lt;td class="event_image"&gt;&lt;img alt="&amp;quot;Inside India&amp;quot; with Larry Kanfer" src="http://testbuzz.illinimedia.com/wp-content/uploads/locations-pics/event-35214.jpg"&gt; &lt;/td&gt;
          &lt;td class="event_title"&gt;“Inside India” with Larry Kanfer&lt;br&gt;
              &lt;i&gt;&lt;span class="location_name"&gt;@ Alice Campbell Alumni Center&lt;/span&gt;&lt;/i&gt;
              &lt;div id="read_more_wrapper"&gt;
              &lt;img src="../../../wp-includes/images/little_pink_arrow.jpg"&gt;&lt;a class="pink_link" href="http://testbuzz.illinimedia.com/events/inside-india-with-larry-kanfer-31"&gt;READ MORE&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
  
        ......more events similar to this......
  
  &lt;div class="fix"&gt;&lt;/div&gt;
                                  &lt;div class="nav-entries"&gt;
                  &lt;a href="http://testbuzz.illinimedia.com/page/2"&gt;&lt;span class="nav-prev icon fl"&gt;Older posts&lt;/span&gt;&lt;/a&gt;                                &lt;div class="fix"&gt;&lt;/div&gt;
              &lt;/div&gt;
  
                  &lt;!-- /#main --&gt;
  
  
  
  &lt;div id="sidebar"&gt;
  
  
      &lt;div class="widget widget_woo_search" id="woo_search-3"&gt;&lt;div class="search_main"&gt;
      &lt;form action="http://testbuzz.illinimedia.com/" class="searchform" method="get"&gt;
          &lt;input type="text" onblur="if (this.value == '') {this.value = 'Search...';}" onfocus="if (this.value == 'Search...') {this.value = '';}" value="Search..." name="s" class="field s"&gt;
          &lt;input type="image" name="submit" class="submit" alt="Search" src="http://testbuzz.illinimedia.com/wp-content/themes/canvas/images/ico-search.png"&gt;
              &lt;/form&gt;    
      &lt;div class="fix"&gt;&lt;/div&gt;
  &lt;/div&gt;
         .... the rest of the content stuck .....
  
  
  &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
  </code></pre>
  
  <p>Below is the code I stuck into our magazine template within our child theme, template-magazine.php, which is causing the problem:</p>
  
  <pre><code>  &lt;?php
                  $page = ( !empty($_REQUEST['page']) &amp;&amp; is_numeric($_REQUEST['page']) )? $_REQUEST['page'] : 1;
    $args = array( 
                 'limit' =&gt; 10,
                 'scope' =&gt; 'today',
                 'pagination' =&gt; 1
                 );
  
  if (isset($_REQUEST['c'])) {
  $args['category'] = $_REQUEST['c'];
  $args['scope'] = 'future';
  }              
  
  
  $args['offset'] = $args['limit'] * ($page-1);
  
  $events = em_get_events_array($args);
  $size = sizeof($events)-1;
  
  
  echo "&lt;h2 id='headding'class='title'&gt;Today's Events&lt;/h2&gt;";
  echo "&lt;table cellpadding='0' cellspacing='0' id='current-events' &gt;";
  
  for ($i=0;$i&lt;$size;$i++) {
  echo "&lt;tr&gt;&lt;td class='startdate_cost_td'&gt;
        &lt;span  class='start_time'&gt;" . $events[$i][0] . 
        "&lt;/span&gt;&lt;br/&gt;&lt;span class='cost'&gt;" . $events[$i][7] . 
        "&lt;/span&gt;&lt;/td&gt;&lt;td class='event_image'&gt;";
  
  
                if ($events[$i][8] == '') {
              echo "&lt;img src='../../../wp-includes/images/default_img.jpg' /&gt;";       
              }
              else {
              echo $events[$i][9];
              }
  
  echo  "&lt;/td&gt;&lt;td class='event_title'&gt;" . $events[$i][10] .
        "&lt;br/&gt;&lt;i&gt;&lt;span class='location_name'&gt;@". $events[$i][11] . 
        "&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;" .$events[$i][12] . 
        "&lt;div id='read_more_wrapper'&gt;" .
        "&lt;img src='../../../wp-includes/images/little_pink_arrow.jpg' /&gt;&lt;a href='" . $events[$i][13] . "' class='pink_link'&gt;READ MORE&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;" . 
        "&lt;/div&gt;";
        } 
  
  echo "&lt;/table&gt;";
  $last_index = count($events) - 1;
  echo $events[$last_index][0];
  ?&gt;
  </code></pre>
  
  <p>I made sure the PHP code above was the cause of the main problems, by removing the code itself. That seems to do the trick! When I tried placing this code in different parts of the template-magazine.php file, it repeated the same results. When I also moved this to the functions.php file in our child theme, it simply made everything else go further down and expand to the whole width of the browser. How do I get rid of the looping in the code, having all of the side content being sucked into the table being created?</p>
  
  <p><strong>UPDATE: I commented out the above PHP code using HTML tags, duplicating the events and commenting out the table elements, which we would like to have show on the page. Below is the screenshot of what it looks like: <a href="https://docs.google.com/open?id=0B2UC67NQiW2yalhMSGxra0FFWGM" rel="nofollow noreferrer">https://docs.google.com/open?id=0B2UC67NQiW2yalhMSGxra0FFWGM</a> and the code that's showing up in the picture below (I didn't want to paste in the code because it would've been very long:</strong>
  <img src="https://i.stack.imgur.com/hlHCd.png" alt="commented out table element, which I would like to have show up on the screen"></p>