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 Acclaimed Member

    Messages:
    3,996
    Likes Received:
    2,248
    Best Answers:
    88
    Trophy Points:
    515
    #2
    It's an input field
     
    malky66, Jul 14, 2013 IP
  3. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #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
    $xmlDoc=new DOMDocument();
    $xmlDoc->load("links.xml");
     
    $x=$xmlDoc->getElementsByTagName('link');
     
    //get the q parameter from URL
    $q=$_GET["q"];
     
    //lookup all links from the xml file if length of q>0
    if (strlen($q)>0)
    {
    $hint="";
    for($i=0; $i<($x->length); $i++)
      {
      $y=$x->item($i)->getElementsByTagName('title');
      $z=$x->item($i)->getElementsByTagName('url');
      if ($y->item(0)->nodeType==1)
        {
        //find a link matching the search text
        if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q))
          {
          if ($hint=="")
            {
            $hint="<a href='" .
            $z->item(0)->childNodes->item(0)->nodeValue .
            "' target='_blank'>" .
            $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
            }
          else
            {
            $hint=$hint . "<br /><a href='" .
            $z->item(0)->childNodes->item(0)->nodeValue .
            "' target='_blank'>" .
            $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
            }
          }
        }
      }
    }
     
    // Set output to "no suggestion" if no hint were found
    // or to the correct values
    if ($hint=="")
      {
      $response="no suggestion";
      }
    else
      {
      $response=$hint;
      }
     
    //output the response
    echo $response;
    ?> 
    PHP:
    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 Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #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 Member

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

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

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #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.