Jump to content

Ajax Suggestion Tutorial On W3schools


I-R-Fool
 Share

Recommended Posts

<?phpheader("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Cache-Control: no-cache");$a[]="Anna";$a[]="Brittany";$a[]="Cinderella";$a[]="Diana";$a[]="Eva";$a[]="Fiona";$a[]="Gunda";$a[]="Hege";$a[]="Inga";$a[]="Johanna";$a[]="Kitty";$a[]="Linda";$a[]="Nina";$a[]="Ophelia";$a[]="Petunia";$a[]="Amanda";$a[]="Raquel";$a[]="Cindy";$a[]="Doris";$a[]="Eve";$a[]="Evita";$a[]="Sunniva";$a[]="Tove";$a[]="Unni";$a[]="Violet";$a[]="Liza";$a[]="Elizabeth";$a[]="Ellen";$a[]="Wenche";$a[]="Vicky";$q = $_GET['q'];if(strlen($q) > 0) {	$hint = "";	for($i=0; $i<count($a); $i++) {				if(strtolower($q) == strtolower(substr($a[$i], 0, strlen($q)))) {						if($hint == "") {								$hint = $a[$i];							} else {							$hint = $hint.", ".$a[$i];						}					}			}}if($hint == "") {	$response = "No Suggestion Found";	} else {		$resposne = $hint;	}echo $response;?>

Link to comment
Share on other sites

I tested your code. I cannot see anything that would cause the error you mentioned. I did notice a typing error here:$resposne = $hint;When I correct it, your code works fine.And there are many places where the PHP uses bad practices, but they shouldn't cause an error. I realize you are copying the code from the school's page, so I am not criticizing you.

Link to comment
Share on other sites

I tested your code. I cannot see anything that would cause the error you mentioned. I did notice a typing error here:$resposne = $hint;When I correct it, your code works fine.And there are many places where the PHP uses bad practices, but they shouldn't cause an error. I realize you are copying the code from the school's page, so I am not criticizing you.
Yea, I fixed that too. It was my mistake. I didn't c/p it. I just wrote it over. I'm quite good at php, but I found it would be faster to rewrite it then to code it myself.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...