If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Related Items

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-29-07, 11:36
triplebig triplebig is offline
Registered User
 
Join Date: Nov 2007
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 11-29-07, 11:58
ortho ortho is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 11-29-07, 12:00
ortho ortho is offline
Registered User
 
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

Quote:
this is a newbie questions and sorry for my english
Es-tu francais?
__________________
Less is more.
How long is now?
http://www.lesouterrain.com

Last edited by ortho; 11-29-07 at 12:03.
Reply With Quote
  #4 (permalink)  
Old 11-29-07, 12:52
triplebig triplebig is offline
Registered User
 
Join Date: Nov 2007
Posts: 2
Quote:
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...


Quote:
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

Quote:

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

Quote:
Es-tu francais?
Non..je suis un malaisien
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On