Mysql PHP搜索内部加入

I'm using MYSql database that outputs like this from my inner join query: enter image description here

Using this query (It works fine)

$result = mysql_query( "
select
   `account`.`name`, `customfield`.`value`, `note`.`occurredondatetime` noteid 
       from  (`note`, `activity`, `ownedsecurableitem` ownedsecurableitem1)
left join `activity_item` on `activity_item`.`activity_id` = `activity`.`id` 
  left join `item` on `item`.`id` = `activity_item`.`item_id` 
    left join `securableitem` on `securableitem`.`item_id` = `item`.`id` 
left join `ownedsecurableitem` on `ownedsecurableitem`.`securableitem_id` = `securableitem`.`id` 
  left join `account` on `account`.`ownedsecurableitem_id` = `ownedsecurableitem`.`id` 
    left join `_user` on `_user`.`id` = `ownedsecurableitem1`.`owner__user_id` 
left join `customfield` on `customfield`.`id` = `account`.`salecyclecstm_customfield_id`

where (`account`.`name` IS NOT NULL) 
  and `activity`.`id` = `note`.`activity_id` 
    and `ownedsecurableitem1`.`id` = `activity`.`ownedsecurableitem_id`
      and (`note`.`occurredondatetime` IS NOT NULL)
       and name='".$_POST['query']."'";

 ORDER BY occurredondatetime DESC

")

 or die("SELECT Error: ".mysql_error());    
  print "<table border=1 >
";  
   $account = "Account";
    $sale = "Sale Cycle";
     $date = "Date";
      print "\t<td><bold><b>$account<b></td>
";
       print "\t<td><bold><b>$sale<b></td>
";
 print "\t<td><bold><b>$date<b></td>
";
  while ($get_info = mysql_fetch_row($result)){  
   print "<P>";
    print "<tr>
";  
     foreach ($get_info as $field) 
      print "\t<td>$field</td>
";
       print "</tr>
";  
        } 
         print "</table>
";

My question is: How would I create a form (Textbox input) that I can search the Account and it will out the Sale Cycle and Date fields (NOT IN A TABLE)? Ideally I would like it to output on the same page, so Java or Ajax?

I have : HTML

<form name="form1" id="form1" method="post" action="search.php"> //change here
Select Name :
<input type="text" name="query" /> 
<input type="submit" name="submit" id="submit" value="search" />
</form>

PHP

$query=mysql_query($select) or die($select);
$numrow=mysql_num_rows($query);
if($numrow != 0)
{
while($row=mysql_fetch_array($query))
{   
<?php echo $row['name'];
<?php echo $row['SalesStages'];

First of all your php coding is wrong.You are using <?php at unwanted places.Please remove it and you have to write a query before you execute it.

<form name="form1" id="form1" method="post" action="search.php"> //change here
Select Name :
<input type="text" name="query" /> 
<input type="submit" name="submit" id="submit" value="search" />
</form>


$query="select * from table where Account='".$_POST['query']."'";
$result = mysql_query($query) or die (mysql_error());
$numrow=mysql_num_rows($result);

while($row=mysql_fetch_array($query))
{   
 echo $row['name'];
 echo $row['SalesStages'];
}

You can create dynamic tables with javascript, here is an example: http://listjs.com/ It allows you to search and sort.