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.

Google's Did You Mean in PHP

Discussion in 'PHP' started by muaazab, Oct 25, 2009.

  1. #1
    Hello,

    I am trying to add artificial intelligence (Google's Did You Mean) in my php/ mysql search. For this purpose I am using following code


    
    
    <?PHP
    $search = $_POST['search'];
    
      $result = mysql_query("Select * From dictionary Where 1 = '1'");
    
    if(mysql_num_rows($result)) 
    
    {
    
    While ($row = mysql_fetch_object($result))
    
    {
    similar_text(strtoupper($search), strtoupper($row->words),
    $similarity_pst);
    
    if(number_format($similarity_pst, 0) > 70)
    
    {
    
    echo $row->words;
    
    }
    }
    }
    ?>
    
    
    PHP:
    The code works very fine. But I am trying to use Max() function instead of
    > 70 to get only one entry of which value is highest. for this my code looks something like this

    
    
    similar_text(strtoupper($search), strtoupper($row->words),
    $similarity_pst);
    
    $percent = $similarity_pst;
    
    if (Max($percent))
    
    {
    
    echo $row->words;
    
    }
    
    
    PHP:

    But this doesn't work. Any help please?

    Thanks
     
    muaazab, Oct 25, 2009 IP
  2. dhaval300

    dhaval300 Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    plz.....store max...value in some variable than try.....got it???
     
    dhaval300, Oct 26, 2009 IP