<html>
 <head><title>MDB tables as HTML</title></head>
<body>
<?php
  
// open file
  
$db mdb_open("test.mdb");

  
// iterate over all tables
  
foreach ( mdb_tables($db) as $name) {
    echo 
"<h1>$name</h1>\n";

    
$tab mdb_table_open($db$name);

    
// show column names
    
echo "<table border='1'>\n";
    echo 
" <tr>";
    foreach (
mdb_table_fields($tab) as $field) {
        echo 
"<th>".$field['name']."</th>";
    }
    echo 
"</tr>\n";

    
// iterate over all rows
    
$n 0;
    while (
$row = (mdb_fetch_row($tab))) {
        echo 
" <tr>";
        foreach (
$row as $val) {
            echo 
"<td>".htmlentities($val)."</td>";
        }
        echo 
"</tr>\n";
        
$n++;
    }
    echo 
"</table>\n";

    echo 
"<p>Rows: $n</p><hr>\n";

    
mdb_table_close($tab);
  }

  
mdb_close($db);
?>
</body>
<html>
 <head><title>MDB tables -&gt; HTML</title></head>
<body>
<h1>Cities</h1>
<table border='1'>
 <tr><th>Province Code</th><th>City Code</th><th>City</th><th>Population</th></tr>
 <tr><td>AB</td><td>CAL</td><td>Calgary</td><td>671326</td></tr>
 <tr><td>AB</td><td>EDM</td><td>Edmonton</td><td>785465</td></tr>
 <tr><td>AB</td><td>LET</td><td>Lethbridge</td><td>58841</td></tr>
 <tr><td>BC</td><td>KEL</td><td>Kelowna</td><td>89730</td></tr>
 <tr><td>BC</td><td>VAN</td><td>Vancouver</td><td>1380729</td></tr>
 <tr><td>BC</td><td>VIC</td><td>Victoria</td><td>255547</td></tr>
 <tr><td>MB</td><td>BRA</td><td>Brandon</td><td>38708</td></tr>
 <tr><td>MB</td><td>THO</td><td>Thompson</td><td>14729</td></tr>
 <tr><td>MB</td><td>WIN</td><td>Winnipeg</td><td>625304</td></tr>
 <tr><td>NB</td><td>FRE</td><td>Fredricton</td><td>44352</td></tr>
 <tr><td>NB</td><td>MON</td><td>Moncton</td><td>55468</td></tr>
 <tr><td>NB</td><td>SAI</td><td>Saint John</td><td>76381</td></tr>
 <tr><td>NF</td><td>COR</td><td>Cornerbrook</td><td>22700</td></tr>
 <tr><td>NF</td><td>MOU</td><td>Mount Pearl</td><td>20200</td></tr>
 <tr><td>NF</td><td>STJ</td><td>St. John's</td><td>96200</td></tr>
 <tr><td>NS</td><td>DAR</td><td>Dartmouth</td><td>65243</td></tr>
 <tr><td>NS</td><td>HAL</td><td>Halifax</td><td>295900</td></tr>
 <tr><td>NS</td><td>SYD</td><td>Sydney</td><td>119470</td></tr>
 <tr><td>NUN</td><td>IQA</td><td>Iqaluit</td><td>4220</td></tr>
 <tr><td>NUN</td><td>RAN</td><td>Rankin Inlet</td><td>2058</td></tr>
 <tr><td>NWT</td><td>HAY</td><td>Hay River</td><td>2964</td></tr>
 <tr><td>NWT</td><td>TUK</td><td>Tuktoyaktuk</td><td>2011</td></tr>
 <tr><td>NWT</td><td>YEL</td><td>Yellowknife</td><td>11753</td></tr>
 <tr><td>ON</td><td>HAM</td><td>Hamilton</td><td>557029</td></tr>
 <tr><td>ON</td><td>OTT</td><td>Ottawa</td><td>819263</td></tr>
 <tr><td>ON</td><td>TOR</td><td>Toronto</td><td>3427168</td></tr>
 <tr><td>PEI</td><td>CHA</td><td>Charlottetown</td><td>53868</td></tr>
 <tr><td>PEI</td><td>SUM</td><td>Summerside</td><td>15614</td></tr>
 <tr><td>QC</td><td>LAV</td><td>Laval</td><td>284164</td></tr>
 <tr><td>QC</td><td>MTR</td><td>Montreal</td><td>2921357</td></tr>
 <tr><td>QC</td><td>QUE</td><td>Quebec City</td><td>603267</td></tr>
 <tr><td>SK</td><td>PRI</td><td>Prince Albert</td><td>40841</td></tr>
 <tr><td>SK</td><td>REG</td><td>Regina</td><td>186521</td></tr>
 <tr><td>SK</td><td>SAS</td><td>Saskatoon</td><td>200665</td></tr>
 <tr><td>YK</td><td>DAW</td><td>Dawson</td><td>896</td></tr>
 <tr><td>YK</td><td>WAT</td><td>Watson Lake</td><td>826</td></tr>
 <tr><td>YK</td><td>WHI</td><td>Whitehorse</td><td>15199</td></tr>
</table>
<p>Rows: 37</p><hr>
<h1>Provinces</h1>
<table border='1'>
 <tr><th>Province Code</th><th>Province</th><th>Capital City</th><th>Population</th><th>Percent</th><th>Date Created</th></tr>
 <tr><td>AB</td><td>Alberta</td><td>Edmonton</td><td>2375278</td><td>9.3</td><td>09/01/05 00:00:00</td></tr>
 <tr><td>BC</td><td>British Columbia</td><td>Victoria</td><td>2889207</td><td>11.4</td><td>07/22/41 00:00:00</td></tr>
 <tr><td>MB</td><td>Manitoba</td><td>Winnipeg</td><td>1063000</td><td>4.2</td><td>07/17/40 00:00:00</td></tr>
 <tr><td>NB</td><td>New Brunswick</td><td>Fredricton</td><td>710442</td><td>2.8</td><td>07/03/37 00:00:00</td></tr>
 <tr><td>NF</td><td>Newfoundland</td><td>Saint John's</td><td>568349</td><td>2.2</td><td>03/31/49 00:00:00</td></tr>
 <tr><td>NS</td><td>Nova Scotia</td><td>Halifax</td><td>873199</td><td>3.4</td><td>07/03/37 00:00:00</td></tr>
 <tr><td>NUN</td><td>Nunavut</td><td>Iqaluit</td><td>24730</td><td>0.1</td><td>04/01/99 00:00:00</td></tr>
 <tr><td>NWT</td><td>Northwest Territories</td><td>Yellowknife</td><td>52238</td><td>0.2</td><td>07/17/40 00:00:00</td></tr>
 <tr><td>ON</td><td>Ontario</td><td>Toronto</td><td>9113515</td><td>35.9</td><td>07/03/37 00:00:00</td></tr>
 <tr><td>PEI</td><td>Prince Edward Island</td><td>Charlottetown</td><td>126646</td><td>0.5</td><td>07/04/43 00:00:00</td></tr>
 <tr><td>QC</td><td>Quebec</td><td>Quebec City</td><td>6540276</td><td>25.8</td><td>07/03/37 00:00:00</td></tr>
 <tr><td>SK</td><td>Saskatchewan</td><td>Regina</td><td>1010198</td><td>4</td><td>09/01/05 00:00:00</td></tr>
 <tr><td>YK</td><td>Yukon Territories</td><td>Whitehorse</td><td>23504</td><td>0.1</td><td>06/15/68 00:00:00</td></tr>
</table>
<p>Rows: 13</p><hr>
</body>