I'm using W3 Schools AJAX and mySQL example here http://www.w3schools.com/php/php_ajax_database.asp
What I have is a table that has different club_id for different venues I deal with ranging from 1-6
So I need to have a way to search the database with the $club_id option
My sql statement is the following.
$club_id=$_GET["club_id"];
$q=$_GET["q"];
$query=mysql_query("SELECT * FROM $table WHERE location_name LIKE '%$%' AND club_id = '$club_id'");
while($row=mysql_fetch_array($query))
{
echo "" .$row['location_name']. "<br>";
}
Now if I take out the AND club_id = '$club_id' option it works fine. But with my site I have example index.php?club_id=2
So I need to be able to only pull the results for club_id=2. But it's not letting me with the livesearch. I have done some changes to the javascript file but again it still works with out the club_id option
Here is my javascript file
var xmlHttp;
function showLocation(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="search.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("result").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
I have also tried adding to the search.php to see if the club_id would pass but it won't.
Is there another way to do this? I just want to have the option to search 1 field in my table and return it back so I can link it to another page
Thoughts?
TIA