Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    290

    Wikipedia API loop

    Hi guys, I making website who use information from wikipedia.
    I use this script:
    PHP Code:
    <?php
    //FUNCTION THAT :PARAMETER - KEYWORD , AND RETURNS WIKI DEFINITION (IN ARRAY FORMAT)
    function wikidefinition($s) {
    //ENGLISH WIKI
        
    $url "http://en.wikipedia.org/w/api.php?action=opensearch&search=".urlencode($s)."&format=xml&limit=[B]10[/B]";
        
    $ch curl_init($url);
        
    curl_setopt($chCURLOPT_HTTPGETTRUE);
        
    curl_setopt($chCURLOPT_POSTFALSE);
        
    curl_setopt($chCURLOPT_HEADERfalse);
        
    curl_setopt($chCURLOPT_NOBODYFALSE);
        
    curl_setopt($chCURLOPT_VERBOSEFALSE);
        
    curl_setopt($chCURLOPT_REFERER"");
        
    curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
        
    curl_setopt($chCURLOPT_MAXREDIRS4);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
        
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
        
        
    $page curl_exec($ch);
        
    $xml simplexml_load_string($page);
        if((string)
    $xml->Section->Item->Description) {
            return array((string)
    $xml->Section->Item->Text
                         (string)
    $xml->Section->Item->Description
                         (string)
    $xml->Section->Item->Url);
        } else {
            return 
    "";
        }
    }
    //END OF FUNCTION WIKIDEFINITIONS



    //USE OF FUNCTION
    $data wikidefinition('A CAPPELLA') ;
    //var_dump( wikidefinition('bangladesh') ) ; //displays the array content
    echo "Word:"       $data[0] . "<br/>";
    echo 
    "Definition:" $data[1] . "<br/>";
    echo 
    "Link:"       $data[2] . "<br/>";
    ?>
    This give me only one result from wikipedia. I wont 10 results, I set this on $url.
    How can I make a loop to print this results.

    Thanks a lot...
    If you come to Belgrade follow this link: Rentacar Stars or Rent a car Beograd Ar
    If you need good web developer, you can visit Izrada sajta

  2. #2
    Registered User
    Join Date
    Feb 2014
    Location
    delhi
    Posts
    572
    Hello ..

    Standard WordPress theme files don’t merely contain HTML and content tags, they also contain The Loop. The Loop is the heart of WordPress output, and it is how WordPress acquires, processes, and iterates through a set of posts to convert them from database table rows to e.g. your blog’s home page.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    290
    It's not for WordPress - this is clear php no CMS...
    If you come to Belgrade follow this link: Rentacar Stars or Rent a car Beograd Ar
    If you need good web developer, you can visit Izrada sajta

Posting Permissions

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

  Find Web Hosting      
  Shared Web Hosting UNIX & Linux Web Hosting Windows Web Hosting Adult Web Hosting
  ASP ASP.NET Web Hosting Reseller Web Hosting VPS Web Hosting Managed Web Hosting
  Cloud Web Hosting Dedicated Server E-commerce Web Hosting Cheap Web Hosting


Premium Partners:


Visit forums.thewebhostbiz.com: to discuss the web hosting business, buy and sell websites and domain names, and discuss current web hosting tools and software.