Q:

How to get all rows from database

my site is  Design Spicy
I am trying to fetch custom table data in wordpress. There are 5 entries in my table, but it shows only first entry. why ?
I want to fetch all rows from table. any suggestions ?
function viewall22() 
{
      global $wpdb;
      $result = $wpdb->get_results( "SELECT * FROM wp_savans");
      foreach($result as $row)    
      {
         $sitemap = '<?php echo $row[name];?>';
      }
}

A:

try this,
function viewall22() 
{
  global $wpdb;
  $sitemap = '';
  $result = $wpdb->get_results( "SELECT * FROM wp_savans", ARRAY_A);
  foreach($result as $row)    
  {
     $sitemap .= $row[name];
  }
  echo $sitemap;
}

