Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    could not print out value

    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 Code:
    <?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

    PHP Code:
    <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==&& 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> 
    Last edited by Inigoesdr; 11-13-2011 at 03:01 AM.

  2. #2
    Supreme Master coder!
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    10,206
    Thanks
    10
    Thanked 1,166 Times in 1,157 Posts
    Maybe the CSS style for your "hints" class is normally hidden or invisible?

    Show us your style sheet.

  3. #3
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    it does not have any css for it yet

  4. #4
    Supreme Master coder!
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    10,206
    Thanks
    10
    Thanked 1,166 Times in 1,157 Posts
    Why do you need a <div> with the class called "hints"?
    Especially if you have no CSS stylesheet.

  5. #5
    Senior Coder Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,651
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You're missing the close quote on your first div line. You are getting an syntax error, and presumably display_errors is off so you get no output. Please remember to read the stickies for this forum. In particular the one about using [php][/php] tags when posting code.

  6. Users who have thanked Inigoesdr for this post:

    kamkam (11-13-2011)

  7. #6
    Supreme Master coder!
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    10,206
    Thanks
    10
    Thanked 1,166 Times in 1,157 Posts
    doh! I didn't see that ... good catch!

  8. #7
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Thanks


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •