| | |
Ajax Search as google?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2009
Posts: 19
Reputation:
Solved Threads: 0
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
google.html
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>![]() |
Similar Threads
- could i search images in a folder using php in offline (PHP)
- How to search data? (JavaScript / DHTML / AJAX)
- sample code for form validation using ajax (JavaScript / DHTML / AJAX)
- google ajax search api ( youtube videoBar) (JavaScript / DHTML / AJAX)
- Google API Search Engine Code (JavaScript / DHTML / AJAX)
- Filtered search function on a website (JavaScript / DHTML / AJAX)
- Image upload using Ajax (PHP)
- Levyo Ajax Gallery supports Firefox 2.0.1 only?? (IT Professionals' Lounge)
Other Threads in the PHP Forum
- Previous Thread: Result without while loop
- Next Thread: contact form
| Thread Tools | Search this Thread |
301 access apache api array autocomplete beginner binary broken button cakephp checkbox class cms code compression cron curl data database dataentry date display dropdown dropdownlist duplicates dynamic echo email error execution file files firstoptioninphpdroplist folder form forms function functions google href htaccess html htmlspecialchars httppost image include insert integration ip javascript joomla jquery limit link links login mail md5 menu methods mlm multiple mysql oop paypal pdf pdfdownload php phpvotingscript query radio random remote script search secure server session sessions source space sql subscription syntax system table tutorial update upload url validator variable video virus volume votedown web white youtube





