title: Only Outputs 1 Row from SQL Database (Using Foreach Loop in PHP)
body: <p>I have 500 rows of cryto data including coin name and symbol in Wordpress database.</p>
  <p>I'm trying to output all of rows using foreach loop and shortcode.</p>
  <p>However, I'm only getting &quot;BTC&quot; row which is the first row of the table.</p>
  <p><a href="https://i.stack.imgur.com/D72SS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D72SS.png" alt="enter image description here" /></a></p>
  <p>My code is this.</p>
  <pre><code>&lt;?php 
  add_shortcode('call_CMC_table', function() {
      global $wpdb;
      $all_coin_data = $wpdb-&gt;get_results( &quot;SELECT * FROM {$wpdb-&gt;prefix}cmc_listing_data&quot;);
  
      foreach ( $all_coin_data as $print_data ) {
          $db_name = $print_data-&gt;name;
          $db_symbol = $print_data-&gt;symbol;
  
          $output =
              '&lt;div class=&quot;ht-container&quot;&gt;
                  &lt;figure class=&quot;ht-post__content table&quot;&gt;
                      &lt;table&gt;
                          &lt;thead&gt;
                          &lt;tr&gt;
                              &lt;th&gt;Coin Name&lt;/th&gt;
                              &lt;th&gt;Coin Symbol&lt;/th&gt;
                          &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                          &lt;tr&gt;
                              &lt;td&gt;'. $db_name .'&lt;/td&gt;
                              &lt;td&gt;'. $db_symbol .'&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/figure&gt;
              &lt;/div&gt;';
  
          return $output; 
      }
  }); 
  ?&gt;
  </code></pre>
  
  <p>What did i do wrong in this code? <strong>I want to loop &quot;&lt; td &gt;&quot; tags in the table</strong>. <em>By the way, I'm learning concept of loop these days and I'm following <a href="https://wordpress.stackexchange.com/questions/51984/how-to-display-data-from-custom-table-in-wordpress-database">this thread</a>.</em></p>