Results 1 to 4 of 4

Thread: Related Items

  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Unanswered: Related Items

    this is a newbie questions and sorry for my english

    im currently working on a simple lyric page

    I have 2 data : title and keyword

    when a user view a particular lyric, i want a related lyric by title & keyword to be display

    example data in database

    title
    Green Day Walking Alone

    Keywords(separated by commas)
    Green Day, walking alone, tabs, midi


    i use this code below but the result display only one title which is the same title as the currently viewed lyric

    PHP Code:
    SELECT titlekeywords FROM lyrics 
    WHERE title LIKE 
    '%".$arr[title]."%'
    AND keywords LIKE '%".$arr[keywords]."%' 

    how to fix this

    is my sql format correct ? can i used Between...AND clause



    thank u in advance

  2. #2
    Join Date
    Nov 2006
    Location
    Quebec
    Posts
    172
    Maybe you can change your AND by a OR ?

    you're using php ?
    Less is more.
    How long is now?
    http://www.lesouterrain.com

  3. #3
    Join Date
    Nov 2006
    Location
    Quebec
    Posts
    172
    You should create a table for your keywords

    Something that look like this:
    id - song_id - keyword

    So your keywords are taken one by one...

    I don't see the rest of your code but if your $arr[keywords] looks like this val1,val2,val3 .... you may not be able to search your data as you want

    this is a newbie questions and sorry for my english
    Es-tu francais?
    Last edited by ortho; 11-29-07 at 13:03.
    Less is more.
    How long is now?
    http://www.lesouterrain.com

  4. #4
    Join Date
    Nov 2007
    Posts
    2
    Maybe you can change your AND by a OR ?

    you're using php ?
    i've done that but not working...

    yes i'm using php..learn from the net and friends


    ok i tested this...i don't know if this format ok to be use

    PHP Code:
    SELECT titlekeywords FROM lyrics 
    WHERE keywords BETWEEN 
    '".$arr[title]."' AND '".$arr[keywords]."' 
    it seems working but only in certain page :-( in other page it listed all the unrelated lyrics...strange ? need to test with more title and keyword...


    You should create a table for your keywords

    Something that look like this:
    id - song_id - keyword

    So your keywords are taken one by one...
    i will try to solve this problem first...if nothing works...i will consider this


    I don't see the rest of your code but if your $arr[keywords] looks like this val1,val2,val3 .... you may not be able to search your data as you want
    yes it looks like that
    can u tell me why..im a noo-b

    Es-tu francais?
    Non..je suis un malaisien

Posting Permissions

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