title: format the results of a database query
body: <p>So far I have the following php which allows the user to search in a specific collumn of the database and displays all the results.</p>
  
  <pre><code>&lt;?php
  require("header.php");
  if(isset($_REQUEST['searching'])){ //check if form has been submitted
  echo"&lt;h2&gt;Results&lt;/H2&gt;&lt;p&gt;";
  connect('final');//connect to DB
  //set the values from search form
  $field = $_POST['field'];
  $query = $_POST['query']; 
  
      $query = htmlspecialchars($query); // stop HTML characters
      $query = mysql_real_escape_string($query); //stop SQL injection
  
       $data = mysql_query("SELECT *
       FROM customer 
       INNER JOIN address ON customer.ID = address.customer_ID
       LEFT OUTER JOIN sites ON address.ID = sites.address_ID 
       WHERE customer.ID IN (SELECT customer.ID 
       FROM customer
       INNER JOIN address ON customer.ID = address.customer_ID 
       LEFT OUTER JOIN sites ON address.ID = sites.address_ID
       WHERE upper(customer.$field) LIKE'%$query%')") ;//query the DB with search field in colleumn selected//
  
       //$data = mysql_query("SELECT * FROM customer INNER JOIN address ON customer.ID = address.Customer_ID LEFT OUTER JOIN sites ON address.ID = sites.address_ID WHERE upper(customer.$field) LIKE'%$query%'") ;
  
      if($data === FALSE) {
      $error = 'Query error:'.mysql_error();
      echo $error;
      }
      else
      {
      while($results = mysql_fetch_array($data)){// puts data from database into array, loops until no more
              echo "&lt;br&gt;"; 
              echo $results['First_Name']; 
              echo " "; 
              echo $results['Surname']; 
              echo " "; 
              echo $results['Company_Name']; 
              echo " "; 
              echo $results['Telephone']; 
              echo " "; 
              echo $results['Alt_Telephone']; 
              echo " "; 
              echo $results['line_1']; 
              echo " "; 
              echo $results['line2']; 
              echo " "; 
              echo $results['town']; 
              echo " "; 
              echo $results['postcode'];
              echo " "; 
              echo $results['site_name'];
  
  
              //posts results from db query
          }
      }
  
  
          $anymatches=mysql_num_rows($data); //checks if the querys returned any results
              if ($anymatches == 0) 
                      { 
                          echo "Sorry, but we can not find an entry to match your query&lt;br&gt;&lt;br&gt;"; 
                      } 
  
      } 
  </code></pre>
  
  <p>However as I am using echo to output it just displays all of the results at the very top of the page, and pushes all of my html content down below it.</p>
  
  <p>How can I format it so that it appears in my html content? below the search button for example.</p>