farad 0 Newbie Poster

Hi there. I was wondering if anyone could help me with this issue I am having. I wanted to create a live ajax search based on the value of the select box. The example I have obtained fromo another website and tried to have a player around. The query works perfectly well only if it is based on one search criteria. I presume that the function is ending and then another is created, but I am not sure.

ajax.php

<html>
<head>
<script type="text/javascript">
function showMake(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } 
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}

function showColour(str1)
{
if (str1=="")
  {
  document.getElementById("txtHint2").innerHTML="";
  return;
  } 
  
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } 
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser.php?c="+str1,true);
xmlhttp.send();
}



</script>
</head>
<body>

<form>
<select name="users" id='make' onchange="showMake(this.value)">	
<option value="">Select a Make:</option>
<option value="Alfa Romeo">Alfa Romeo</option>
<option value="Austin">Austin</option>
<option value="Bentley">Bentley</option>
<option value="BMW">BMW</option>
<option value="Daewoo">Daewoo</option>
<option value="Datsun">Datsun</option>
<option value="Fiat">Fiat</option>
<option value="Ford">Ford</option>
<option value="Honda">Honda</option>
<option value="Isuzu">Isuzu</option>
<option value="Jaguar">Jaguar</option>
<option value="Jeep">Jeep</option>
<option value="Kia">Kia</option>
<option value="Landrover">Landrover</option>
<option value="Lexus">Lexus</option>
<option value="Lotus">Lotus</option>
<option value="Mazda">Mazda</option>
<option value="Mercedes">Mercedes</option>
<option value="MG">MG</option>
<option value="Nissan">Nissan</option>
<option value="Peugeot">Peugeot</option>
<option value="Renault">Renault</option>
<option value="Rover">Rover</option>
<option value="Toyota">Toyota</option>
<option value="Vauxhall">Vauxhall</option>
<option value="Volvo">Volvo</option>
<option value="VW">VW</option>

</select>
</form>

<form>
<select name="make" id='colour' onchange="showColour(this.value)">	
<option value="">Select a Colour:</option>
<option value="red">Alfa Romeo</option>

</select>
</form>

<br />
<div id="txtHint"><b>Select Make.</b></div>
<div id="txtHint2"><b>Select Colour.</b></div>

</body>
</html>

getuser.php

<?php
@$q=$_GET["q"];
@$c=$_GET["c"];

$odbc = mysql_connect('localhost','root','') or die ("Can't connect to server");

	mysql_select_db('car', $odbc) or die ("Database does not exist");
	
	



$sql="SELECT * FROM cars WHERE make= '$q' AND colour = '$c' Limit 10";

	$result = mysql_query($sql, $odbc) or die ("Can't run query");


echo "
	
<table border ='1' width='80%' cellpadding='10	 cellspacing='0'>
			<tr>
				

				
			</tr>
		";	
while ($row=mysql_fetch_object($result))

{

			echo
			
			"	
			
			<tr border='5'>
				<td><img id='t' src=$row->image width='100' height='100'></td>
				<td rowspan='1' valign='top' align='left' colspan='1'><b>$row->make: &nbsp; $row->model</b> <br /><br />$row->dealer <br />
				
				<hr />
				$row->colour | $row->Reg(reg) | $row->miles | | $row->town | $row->region | &nbsp;<a id='a' href='moredetails.php'?carID=$row->carIndex> More-Details</td> 
				
				<td><b>£$row->price</b></td>
			</tr>
			
			";
			

	
}

echo "</table>";



mysql_close($odbc);
?>

I want to also be able to search based on miles etc, but if the above is not possible then I am happy either way.

Thanks.