title: select name from php query and refresh seprate query on same page.
body: <p>I have just used my first bit of AJAX to search a MySQL database. This is for a persons name I would normally add a href to the result (which i have) and post to a seprate page to show all the the relevant details, eg address, grade and location. However i was wondering if this is possible staying on the same page. This is what i have so far. ( and yes the CSS will be moving to a seprate page)</p>
  
  <pre><code>&lt;?php
  if(!strlen(trim($_SESSION['Unique_Id']))) {
   header("Location:roster.php");
   exit();
  }
  ?&gt;
  &lt;title&gt;Search Roster&lt;/title&gt;
      &lt;style&gt;
          body {
              font-family: "Lucida Grande", Verdana, Arial, sans-serif;
              font-size: 12px;
          }
          #results {
              color: #fff;
              background: #414141;
              width: 180px;
              max-height: 200px;
              padding-left: 4px;
              border: 1px solid #000;
              overflow-y: scroll;
              overflow-x: hidden;
          }
          a { color: #fff; display: block; }
          a:hover { background: #666666; }
  
  &lt;/style&gt;
      Keyword Search:
      &lt;form id="searchform" method="post" onsubmit="return false;"&gt;&lt;input autocomplete="off" id="searchbox" name="searchq" onkeyup="sendRequest()" type="textbox"&gt;
      &lt;/form&gt;&lt;div id="show_results"&gt;&lt;/div&gt;&lt;script src="config/prototype.js" type="text/javascript"&gt;
  &lt;/script&gt;
      &lt;script&gt;
  function sendRequest() {new Ajax.Updater('show_results', 'pages/login/search.php', { method: 'post', parameters: $('searchform').serialize() });
          }
  
  &lt;/script&gt;
  &lt;?php include("pages/include/footer.php"); ?&gt;  
  </code></pre>
  
  <p>and the search.php page</p>
  
  <pre><code>&lt;?php
  $host="****"; // Host name 
  $sqlusername="****"; // Mysql username 
  $sqlpassword="****"; // Mysql password 
  $db_name="****"; // Database name 
  $tbl_name="****"; // Table name
  mysql_connect("$host", "$sqlusername", "$sqlpassword")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  $searchq = $_POST['searchq'];
  if(empty($searchq)) {
  echo "";
  } else {
  echo "&lt;div id='results'--&gt;"; 
   //This query searches the name field for whatever the input is.
   $sql = "SELECT * FROM USER WHERE Employee LIKE '%$searchq%' OR staff LIKE '%$searchq%'";
           echo "&lt;table border='3'&gt;
  &lt;tr&gt;
  &lt;/tr&gt;";
  $result = mysql_query($sql);
  while($row = mysql_fetch_assoc($result)) {
      $name = $row['EmployeeName'];
      $id=$row['Unique_Id'];
      echo "&lt;a href=anotherpage.php?item=".$id."&lt;/a&gt;";
      echo "$name";
  
  
              echo "&lt;/br&gt;";  
      }           
      echo "&lt;/div&gt;";
  }
  ?&gt;
  </code></pre>