<? $title="Displaying Select Results";
   
$bgcolor="#def";
   include(
'./head.inc');
?>
<p>

<?php
    $host
="localhost";
    
$uid="metwo";
    
$pass="fullspeed";
    
$dbname="wdp2test";
    include_once(
"mysql.inc");  // sets $link

    
$query = "SELECT * FROM PWANG_TABLE";
    
$result = @mysql_query($query, $link);  // $result may be null

    
if ( $result == null || mysql_num_rows($result) == 0 )
    {   print
"<p>No results are found.</p>";  
        exit();
    }

    
$header_printed = false;
    print
"<table border='1'>\n";

    while(
$data = mysql_fetch_assoc($result) )
    {  
// table header
       
if (!$header_printed)
       {  print
" <tr>";
      foreach(
$data as $field => $value)
          {   print
"  <th> $field  </th>\n"; }
          print
" </tr>\n";
          
$header_printed = true;
       }
       
// table rows
       
print " <tr><td>";
       
// glues between row values
       
print implode("</td><td>", $data);
       print
"</td></tr>\n";
    }
    print
"</table>\n";
    
mysql_free_result($result);
?>
</p></body></html>