Hi frnds....
i am trying to do search like google....
my files r here......but it displays nothing....i mean no output and no error...plz check the code what the error?
eg: in a text box type "a"
then "a" related words r displayed...
google.phpp
<?php
$file=fopen("http://www.google.com/complete/search?h1=en&js=true&qu=" . $_GET["qu"],"r");
while(!feof($file)){
$d=fgets($file);
echo $d;
echo "no";
}
fclose($file);
?>
google.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>google search</title>
<script language="javascript">
function getData(dataSource)
{
var XMLHttpRequestObject = false;
if(window.XMLHttpRequest){
XMLHttpRequestObject=new XMLHttpRequest();
}else if(window.ActiveXObject){
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}
if(XMLHttpRequestObject){
XMLHttpRequestObject.open("GET",dataSource);
XMLHttpRequestObject.onreadystatechange=function(){
if(XMLHttpRequestObject.readyState ==4 && XMLHttpRequestObject.status==200){
eval(XMLHttpRequestObject.responseText);}
}
XMLHttpRequestObject.send(null);
}
}
function connectGoogleSuggest(keyEvent){
var input=document.getElementById("textField");
if(input.value){
getData("google.php?qu=" +input.value);
}else{
var targetDiv=document.getElementById("targetDiv");
targetDiv.innerHTML= "<div></div>";
}
}
function sendRPCDone(unusedVariable,searchTerm,arrayTerm,arrayResults,unusedArray){
var data="<table>";
var loopIndex;
if(arrayResults.length !=0){
for(var loopIndex=0; loopIndex < arrayResults.length; loopIndex++){
data +="<tr><td>" + "<a href='http://www.google.com/search?q=" + arrayTerm[loopIndex] +"'>" +arrayTerm[loopIndex] +'</a></td><td>' + arrayResults[loopIndex] + "</td></tr>";
}
}
data +="</table>" ;
var targetDiv=document.getElementById("targetDiv");
targetDiv.innerHTML=data;
}
</script>
</head>
<body>
<input id="textField" type="text" name="textField" onkeyup="connectGoogleSuggest(event)" />
<div id="tagetDiv" ><div></div></div>
</body>
</html>