1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

what is this part of the form called ?

Discussion in 'PHP' started by gether, Jul 14, 2013.

  1. #1
    [​IMG]
    gether, Jul 14, 2013 IP
  2. malky66

    malky66 Prominent Member

    Messages:
    1,712
    Likes Received:
    1,049
    Best Answers:
    27
    Trophy Points:
    390
    #2
    It's an input field
    malky66, Jul 14, 2013 IP
  3. gether

    gether Greenhorn

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #3
    ok .. so the input feild has an id ...

    trying to implement a live search in that input feild
    [​IMG]

    [​IMG]
    The source code in "livesearch.php" searches an XML file for titles matching the search string and returns the result:
    PHP:
    1. <?php
    2. $xmlDoc=new DOMDocument();
    3. $xmlDoc->load("links.xml");
    4.  
    5. $x=$xmlDoc->getElementsByTagName('link');
    6.  
    7. //get the q parameter from URL
    8. $q=$_GET["q"];
    9.  
    10. //lookup all links from the xml file if length of q>0
    11. if (strlen($q)>0)
    12. {
    13. $hint="";
    14. for($i=0; $i<($x->length); $i++)
    15.   {
    16.   $y=$x->item($i)->getElementsByTagName('title');
    17.   $z=$x->item($i)->getElementsByTagName('url');
    18.   if ($y->item(0)->nodeType==1)
    19.     {
    20.     //find a link matching the search text
    21.     if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q))
    22.       {
    23.       if ($hint=="")
    24.         {
    25.         $hint="<a href='" .
    26.         $z->item(0)->childNodes->item(0)->nodeValue .
    27.         "' target='_blank'>" .
    28.         $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
    29.         }
    30.       else
    31.         {
    32.         $hint=$hint . "<br /><a href='" .
    33.         $z->item(0)->childNodes->item(0)->nodeValue .
    34.         "' target='_blank'>" .
    35.         $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
    36.         }
    37.       }
    38.     }
    39.   }
    40. }
    41.  
    42. // Set output to "no suggestion" if no hint were found
    43. // or to the correct values
    44. if ($hint=="")
    45.   {
    46.   $response="no suggestion";
    47.   }
    48. else
    49.   {
    50.   $response=$hint;
    51.   }
    52.  
    53. //output the response
    54. echo $response;
    55. ?>
    now i need to make sense of this code


    <html>
    <script>
    javascript
    javascript function
    livesearch.php

    <?php

    livesearch.php
    <?xml
    file.xml
    Last edited: Jul 14, 2013
    gether, Jul 14, 2013 IP
  4. ryan_uk

    ryan_uk Prominent Member

    Messages:
    3,943
    Likes Received:
    991
    Best Answers:
    33
    Trophy Points:
    365
    #4
    So, do you want all that above code explaining? I suggest you look functions up at www.php.net and experiment with each one, so that you understand what they do. Then you will be able to read the code and understand the whole.
    ryan_uk, Jul 14, 2013 IP
  5. gether

    gether Greenhorn

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #5
    [​IMG]

    its ok.. i was completly lost...
    gether, Jul 15, 2013 IP
  6. ryan_uk

    ryan_uk Prominent Member

    Messages:
    3,943
    Likes Received:
    991
    Best Answers:
    33
    Trophy Points:
    365
    #6
    ryan_uk, Jul 15, 2013 IP
  7. Jamendo

    Jamendo Banned

    Messages:
    9
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    18
    #7
    It is input type = text which means you are going to input in text format. It will be used to enter data by the user and can be read by any server side scripting and can be used later to process on data
    Jamendo, Jul 15, 2013 IP
    EchoTek likes this.