将SQL数据放入HTML表。 表头是重复的

I'm trying to get the data from my mySQL database and put them into a HTML table. After searching a lot on the internet, but I coudn't find code that worked for me.

Currently, I have this code

**<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$user = "root";
$password = "";

$db = mysql_connect('localhost', $user, $password);

if (!$db) {
    die('Not connected : ' . mysql_error());
}

$dbname = "btcx2";

          $db_select = mysql_select_db($dbname,$db);
            if (!$db_select) {
                die("Database selection also failed miserably: " . mysql_error());
            }

            $results = mysql_query("SELECT btcaddress, btclink, btcreceived , btctarnsaction, lastdeposit, reg_date, uptodate , btcdoubble FROM btctrans");
            while($row = mysql_fetch_array($results)) {

            ?>
  <table style="width:95%;height:95%;" border="2">
     <thead>
        <tr>
            <th><strong>Date</strong></th>
            <th><strong>BTC Address</strong></th>
            <th><strong>Amount Deposited</strong></th>
            <th><strong>Amount Returned</strong></th>
            <th><strong>Transaction</strong></th>
        </tr>
    </thead>
    <tbody>     

    <tr>
                [<td><font color="red"> <?php echo $row\['reg_date'\]?></font></td>
                <td> <a href="<?php echo $row\['btclink'\]?>"><?php echo $row\['btcaddress'\]?></a></td>
                <td><font color="red">BTC: <?php echo $row\['btcreceived'\]?> </font></td>
                <td><font color="red">BTC: <?php echo $row\['btcdoubble'\]?></font></td>
                <td><font color="red"> <?php echo $row\['btctarnsaction'\]?></font></td>][1]

            </tr>

            <?php
        }
        ?>  


        </tbody>
        </table></center>**

Every time when the data is inserted, table headers are repeated with the table data . i used "mysql_connect" and not "mysqli" . please some one fix this help me on this problem.

here is a picture of the error : - http://i.stack.imgur.com/1yOZ3.png

You need to put table headers before (out of loop)

Your headers are repeating for every record.

The should come only once.

Corrected code:

<table style="width:95%;height:95%;" border="2">
<thead>
 <tr>
  <th><strong>Date</strong></th>
  <th><strong>BTC Address</strong></th>
  <th><strong>Amount Deposited</strong></th>
  <th><strong>Amount Returned</strong></th>
  <th><strong>Transaction</strong></th>
 </tr>
 </thead>
<?php
while($row = mysql_fetch_array($results)) {
?>