Hi;
My problem is i could not print out value after i inserted echo "<div class=\"hints\">; and echo "</div>"; please see the highline .
I am implementing an auto suggestiion for search engin.
response.php
<?php
$q=$_GET["q"];
include("../condatabase.php");
$sql="SELECT content FROM articles WHERE content like '%".$q."%'";
$result = mysql_query($sql);
$a[]=""; $m[]="";
while($row = mysql_fetch_array($result)){
$m.= $row['content'];
}
//$final = preg_match_all("/talking a[a-zA-Z]*/", $string);
$term="/" . $q . "[a-zA-Z\s]*" . "/";
preg_match_all($term, $m,$f);
$count=count($f[0]);
$f[0]=array_unique($f[0]);
$i=0;
while($i<$count){
$a[$i]=($f[0][$i]);
echo "<div class=\"hints\">;
echo $a[$i]; // i could not print out this value, but it can do without two div
echo "</div>";
$i++;
}
?>
-------------------------------------------------------------------
index.php
<html>
<head>
<script type="text/javascript">
function showHint(str)
{
var xmlhttp;
if (str.length==0)
{
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","response.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<h3>Start typing a name in the input field below:</h3>
<form action="">
First name: <input type="text" id="txt1" onkeyup="showHint(this.value)" />
</form>
</body>
</html>
My problem is i could not print out value after i inserted echo "<div class=\"hints\">; and echo "</div>"; please see the highline .
I am implementing an auto suggestiion for search engin.
response.php
<?php
$q=$_GET["q"];
include("../condatabase.php");
$sql="SELECT content FROM articles WHERE content like '%".$q."%'";
$result = mysql_query($sql);
$a[]=""; $m[]="";
while($row = mysql_fetch_array($result)){
$m.= $row['content'];
}
//$final = preg_match_all("/talking a[a-zA-Z]*/", $string);
$term="/" . $q . "[a-zA-Z\s]*" . "/";
preg_match_all($term, $m,$f);
$count=count($f[0]);
$f[0]=array_unique($f[0]);
$i=0;
while($i<$count){
$a[$i]=($f[0][$i]);
echo "<div class=\"hints\">;
echo $a[$i]; // i could not print out this value, but it can do without two div
echo "</div>";
$i++;
}
?>
-------------------------------------------------------------------
index.php
<html>
<head>
<script type="text/javascript">
function showHint(str)
{
var xmlhttp;
if (str.length==0)
{
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","response.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<h3>Start typing a name in the input field below:</h3>
<form action="">
First name: <input type="text" id="txt1" onkeyup="showHint(this.value)" />
</form>
</body>
</html>