title: Dynamic table with headings and subheadings taken from database
body: <p>I am echoing a list of areas covered as hypertext links taken from a database,</p>
  
  <pre><code>$area_shire = '';
  $area_district = '';
  $area_name = '';
  
  while($rows = mysql_fetch_assoc($query)) {
  
      if ($rows['area_shire'] != $area_shire) {
          $area_shire = $rows['area_shire'];
          $area_shire_url = str_replace(' ', '_', $area_shire);
          echo '&lt;h2&gt;&lt;a href=Driveway_Cleaning_'.$area_shire_url.'&gt;'.$area_shire.'&lt;/a&gt;&lt;/h2&gt;&lt;br&gt;';
      }  
  
  
      if ($rows['area_district'] != $area_district) {
          $area_district = $rows['area_district'];
          $area_district_url = str_replace(' ', '_', $area_district);
          echo '&lt;h3&gt;&lt;a href=Driveway_Cleaning_'.$area_district_url.'&gt;'.$area_district.'&lt;/a&gt;&lt;/h3&gt;&lt;br&gt;';
  
      }  
  
  
      if ($rows['area_name'] != $area_name) {
          $area_name = $rows['area_name'];
          $area_name_url = str_replace(' ', '_', $area_name);
          echo '&lt;a href=Driveway_Cleaning_'.$area_name_url.'&gt;'.$area_name.'&lt;/a&gt;&lt;br&gt;';
      }  
      }
  ?&gt;
  </code></pre>
  
  <p>This is Giving me a linear output of</p>
  
  <h2>West Midlands</h2>
  
  <h3>Birmingham</h3>
  
  <p>Harborne<br>
  Edgbaston<br>
  Moseley<br></p>
  
  <h3>Dudley</h3>
  
  <p>Halesowen<br>
  Sedgley<br></p>
  
  <h2>Warwickshire</h2>
  
  <p>I am trying to put the output into a dynamic table so each area_district (e.g) Dudley starts in a new column and is therefore to the right of Birmingham rather than below. Everything i try is affecting the order of the output. Any ideas?  </p>