Forum Moderators: coopster

Message Too Old, No Replies

Get value from other table and show its label

         

marovios

6:16 pm on May 30, 2005 (gmt 0)

10+ Year Member



Hi, sorry if this is not the proper forum to post this.

Look, i have php page that lists a bunch of records. This records are store in a table named "lyrics" that has three fields: title, lyrics and id_author (it's a foreing key). Now, on the other hand, i have other table named "authors" and it containes two fields: id_author and author_name, ok?

I already create a "master page" that lists all lyrics and a "detail page" and they are working just fine.

What i want to do and don't know how, is that on each detail lyric page i want to put the author's name. I put the id_author from the "author" table and of course it shows me the id_author, but i need the NAME of the author.

See my point?, there should be a way to create a relationship between the id_author from the "author" table and the id_author from the "lyrics" table and this relationship should give me the "author_name" value, not the "id_author" value.

Ok, i hpe i made my self clear, let me know if someone know how to solve this.

Many thanks to all of you.

Terkin

9:04 pm on May 30, 2005 (gmt 0)

10+ Year Member


query:
"select lyrics.title, lyrics.lyrics, author.author_name from lyrics, author where lyrics.id_author=author.id_author"

coopster

9:55 pm on May 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You are describing what is called TABLE JOINS and Terkin has given you an example.

Welcome to WebmasterWorld, Terkin.

marovios

11:05 pm on May 30, 2005 (gmt 0)

10+ Year Member



Hi again coopster.
Hi Terkin, thanks for the example.
I'm gonna try that.

Thanks guys.

marovios

8:43 pm on May 31, 2005 (gmt 0)

10+ Year Member



Hi guys!. Thank you so much. Everything went just perfect!
I've already said it: this is a great forum!
See ya.