SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: duplicated

  1. #1
    SitePoint Guru defiance's Avatar
    Join Date
    Oct 2004
    Location
    United states
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    duplicated

    hi there,,,

    i have a query

    PHP Code:
    for ($i 0$i <= $noskeyword$i++) { 

    $descriptionQuery="SELECT * 
                FROM news 
                WHERE (
           subject like '%"
    .$keyword[$i]."%'
        or content like '%"
    .$keyword[$i]."%'
           )  "
    ;

        
    $descriptionResult mysql_query($descriptionQuery) or die(mysql_error()); 



        while (
    $rowDescription mysql_fetch_array($descriptionResult,2)) { 
            
    $resultOut[] = $rowDescription
       } 


    so everything works well and the final result is in $resultOut


    however my resukt are being duplicated.

    do you guys see why is it being duplicated?

    thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    either you have duplicated data (which is easy to do, if you load a file twice), or else you have a programming problem

    it's real easy to determine which is it, and that is to always test your queries outside of php before embedding them in a php script

    this will help you decide whether to post your questions in the mysql forum or the php forum

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru defiance's Avatar
    Join Date
    Oct 2004
    Location
    United states
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks


    i checked my database

    there is no duplicated data...

    ..................................

    what should i do?

  4. #4
    SitePoint Guru defiance's Avatar
    Join Date
    Oct 2004
    Location
    United states
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my quess is that there is something wrong with the for loop.

    what i am trying to achieve is that

    to search my database which contains keywords ( more than one keyword ) either appear in the subject or content...........

    please enlighten me..................

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Location
    Glasgow, Scotland
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should post the whole code.

  6. #6
    SitePoint Guru defiance's Avatar
    Join Date
    Oct 2004
    Location
    United states
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah.....

    i am sorry

    my bad...

    i entered the wrong keyword.

    now it is working.....
    i am sorry once again

    and thank you very much for your help,..


Bookmarks

Posting Permissions

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