Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

could not print out value

Status
Not open for further replies.

dldl

Programmer
May 3, 2010
40
NZ
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>
 
You are missing the closing set of double quotes in your echo statement:

Code:
echo "<div class=\"hints\">[red]>>_<<[/red];

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top