Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder student's Avatar
    Join Date
    Jan 2007
    Posts
    129
    Thanks
    13
    Thanked 0 Times in 0 Posts

    how to hide duplicate search results?

    hello,
    i have a PHP script directory with an MYSQL database and it has some duplicate records.
    the directory has a search functionality and duplicate results are showing up in the search results.
    i would like to hide these duplicate results ( but dont want to delete them ).
    all the records have a 'unique item' and i would like to filter the results using this 'unique item' ( so that a record with the same 'unique item' should not appear more than once )

    please inform me how to filter my search results to avoid duplicates.
    i am new to PHP and MYSQL. please inform me the possible code.
    thank you

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    you filter the results by not getting them in your sql statement in the first place.

    please show some sample rows from your table as well as the output you would like to see from those rows and then show the sql query you are currently using.

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    From an email from the OP I will post their additional info here for all to see.

    Code:
    the table is:
    cb_urls (
    id int(11) NOT NULL auto_increment,
    poll_id int(11) NOT NULL default '0',
    link_count int(11) default '0',
    popularityrank int(7) default '0',
    destination varchar(12) NOT NULL default '',
    title varchar(70) default NULL,
    description text(400),
    category varchar(100) default NULL,
    PRIMARY KEY (id),
    KEY category (category)
    )";
    there are some rows with the same 'destination', 'title', 'description', but with different
    id, poll_id, popularityrank etc...
    i would like to ensure that no row with the same 'destination' should repeat in the search results.
    and order the results by popularity rank.

    the query is:
    PHP Code:
    $sth mysql_query("SELECT * FROM cb_urls WHERE category='".addSlashes(strtolower($keywords))."' OR title LIKE '%".addSlashes(strtolower($keywords))."%' or description LIKE '%".addSlashes(strtolower($keywords))."%' GROUP BY popularityrank LIMIT $mdf_startbound, $perpage"); 

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    that shows your table but you also need to show some rows in the table and the output you want.

    Show us where you have multiple destinations that are the same and then show us what row you want from those duplicates and explain the logic behind choosing that row and not one of the other rows with the same destination.

  • #5
    Regular Coder student's Avatar
    Join Date
    Jan 2007
    Posts
    129
    Thanks
    13
    Thanked 0 Times in 0 Posts
    hello,
    thanks for your reply,
    the example page is here:
    http://downloadsonline.org/search.php?keywords=psp

    destination field is hidden.
    some rows have same destination, title, description but have different id, poll_id, popularityrank etc.

    i would like to ensure that no row with the same destination or title or description repeat in the results.

    can i make a query like this:

    $sth = mysql_query("SELECT * FROM cb_urls WHERE destination != destination, category='".addSlashes(strtolower($keywords))."' OR title LIKE '%".addSlashes(strtolower($keywords))."%' OR keywd LIKE '%".addSlashes(strtolower($keywords))."%' or description LIKE '%".addSlashes(strtolower($keywords))."%' GROUP BY popularityrank LIMIT $mdf_startbound, $perpage");

    thank you very much.

    ( yesterday i posted a pm with the reply because, i could not make a reply in the forum. even after waiting for a longtime, the hoverglass icon appeared without posting the reply. )

  • #6
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    so do you think you could actually post some sample rows here, (not some obscure link that we are supposed to figure out what we are looking at), and within those four or five rows contain duplicate information that you want to weed out, and then show us of those four or five rows, which one you want as the only result returned and why?

    here is an example:

    black cow 1
    black cow 2
    black turtle 3
    black cow 4

    I want the black turtle returned because it is the only turtle, and I wante black cow 1 returned because it has the lowest numeric value of the three cows.

    If you can do something like that it will most likely ensure that you can get assistance with your problem.

    As for the posting problem, I'd say to hit stop and try to reload a web page when that happens.


  •  

    Posting Permissions

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