title: PHP PDO while doesn't achieve my desire end result
body: <p>This is my first posting in SO, my apologize if I opened an existing question. As I couldn't find the result in Google. Sorry to said but I'm still fresh in PHP PDO and in learning stage.</p>
  
  <p>Back to my question, currently I'm building a customer visit logs from my wife but I'm stuck with the result. I have two table which one stores the customer information and another table store the visit details. I uploaded the test table at here: <a href="http://sqlfiddle.com/#!2/01d3ea/1" rel="nofollow">SQL Fiddle</a></p>
  
  <p>And below is my current coding and I'm using PHP PDO <strong>while</strong></p>
  
  <pre><code>&lt;?php
  
  require_once 'dbconnect.php';
  
  $p_id = $_GET['name'];
  
  try {
  $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
  
  $sql = "SELECT customer.fname, customer.lname, customer.gender, services.treatment, services.date
            FROM customer LEFT JOIN services
            ON customer.id = services.customer_id
            WHERE customer.slug  LIKE :id";
  
  $q = $conn-&gt;prepare($sql);
  $q-&gt;execute(array('id' =&gt; $p_id));
  $q-&gt;setFetchMode(PDO::FETCH_ASSOC);
  
  } catch (PDOException $pe) {
  die("Could not connect to the database $dbname :" . $pe-&gt;getMessage());
  }
  
   ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="container"&gt;
  &lt;h1&gt;Customer Record&lt;/h1&gt;
  Name: &lt;br /&gt;
  Gender: &lt;br /&gt;    
  &lt;table class="table table-bordered table-condensed"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Customer Name&lt;/th&gt;
              &lt;th&gt;Customer Gender&lt;/th&gt;
              &lt;th&gt;Treatment&lt;/th&gt;
              &lt;th&gt;Date&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;?php while ($r = $q-&gt;fetch()): ?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;?php echo htmlspecialchars($r['fname']), ' ', htmlspecialchars($r['lname'])?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo htmlspecialchars($r['gender']); ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo htmlspecialchars($r['treatment']); ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo htmlspecialchars($r['date']); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php endwhile; ?&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
      &lt;a href="search.html"&gt;Seach Again&lt;/a&gt;
  &lt;/body&gt;
  &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And I achieve as what SQL Fiddle result, but what I wanted is, the name and gender is not keep repeating.</p>
  
  <p>I attached together with the screenshot:</p>
  
  <p><a href="http://i.imgur.com/FNdtdIr.jpg" rel="nofollow">Screenshot</a></p>
  
  <p>What I want is as per the screenshot image, <strong>Name:</strong> John Doe and <strong>Gender:</strong> Male, should be on top and not keep on repeating while the table below show all the visit details. I tried to modified the code but it seems it don't really work out.</p>
  
  <p>Please advise me as I'm really out of idea how to achieve what I want.</p>
  
  <p>Thank you so much.</p>