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.

search weigths

Discussion in 'PHP' started by trichnosis, Nov 30, 2007.

  1. #1
    Hi;

    I'm working on a search script and i want to assign weigths for different criterias for my articles like

    title %15
    content %50
    hits %5
    creation date %10
    (maybe more criterias come here:))

    etc.

    I need ideas for this or any articles which is related with this.

    Thanks for the comments
     
    trichnosis, Nov 30, 2007 IP
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I suggest something like this :

    1 - Fetch the results of a DB query like this ("SELECT title, content,... FROM db_table WHERE some strings comparaison is true") on an array

    2 - for each table row generate a % for each criteria, for example :
    * Title % will be equal to : (15 * number_of_search_terms_found / number_of_search_terms)%
    * Same for content
    * The table row with the biggest hits value will have a % of 5 for the hits criteria, and the row with the lowest hits count will have 0%, other rows well be calculated :
    hits % = (5 * row_hits_count/biggest_hits_count)%
    * Same for creation date (using timestamp instead of hits count).

    Then calculate the criterias % total and sort the table.


    Sorry for mistakes... I wrote this in a hurry !
     
    selling vcc, Nov 30, 2007 IP