How to show number results found for search query in my site?

Discussion in 'PHP' started by karimian, Feb 17, 2010.

  1. #1
    How to show number results found for search query in my site?
    http://search.yahoo.com/search;_ylt=A0geutkDOWxLDoUBfbVXNyoA?p=site:mixx.com+linkdomain:cnet.com
     
    karimian, Feb 17, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    <?php
    
    preg_match("/<strong id=\"resultCount\">([0-9,]*)<\/strong> results for<\/span>/", file_get_contents("http://uk.search.yahoo.com/search?p=site:mixx.com+linkdomain:cnet.com"), $matches);
    
    echo $matches[1]." Results";
    
    ?>
    PHP:
     
    danx10, Feb 17, 2010 IP
  3. karimian

    karimian Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for replay.
    How to add Yahoo API code to this code?
     
    karimian, Feb 17, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Im not familiar with the Yahoo API, but here is a more clear version of the code I posted.

    <?php
    
    $query = "site:mixx.com+linkdomain:cnet.com";
    
    preg_match("/<strong id=\"resultCount\">([0-9,]*)<\/strong> results for<\/span>/", file_get_contents("http://uk.search.yahoo.com/search?p=".$query), $matches);
    
    $numberofresults = $matches[1];
    
    echo $numberofresults;
    ?>
    PHP:
     
    danx10, Feb 17, 2010 IP
  5. karimian

    karimian Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Please help me How to add Yahoo API code to this code?
    <?php
    
    $query = "site:mixx.com+linkdomain:cnet.com";
    
    preg_match("/<strong id=\"resultCount\">([0-9,]*)<\/strong> results for<\/span>/", file_get_contents("http://uk.search.yahoo.com/search?p=".$query), $matches);
    
    $numberofresults = $matches[1];
    
    echo $numberofresults;
    ?>
    Code (markup):
     
    karimian, Feb 17, 2010 IP
  6. karimian

    karimian Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    How to replace cnet.com with <? echo $website; ?>
     
    karimian, Feb 18, 2010 IP