Page 1 of 1

Need help with Fields & Database

Posted: Wed Oct 08, 2003 2:56 am
by wizzard
Hello,

I'm working on a members profile => My members can add a music profile of them with personal info, music info, songs info.

I have some problems with Songs info i want something that users can unlimited songsinfo(track name, Url, Song Info). Anyone an advice how i can fix this so when users register they get the chance to add in their Profile unlimited songs info. Like Song1, Song2, Song3.


Cheers
Kris

Posted: Wed Oct 08, 2003 3:02 am
by Paddy
Have two different tables with a key to join them. For example
MEMBER
memberid, profile, music

SONGS
memberid, song

The first table will have unique memberids but the second table can have as many memberids as there are songs. eg.

001001, song1
001001, song2
001001, song3

Hope that helps.

Posted: Wed Oct 08, 2003 3:12 am
by wizzard
But how can i fix this in the form? because i don't know how much songs they have. I can not add like 10 fields or 20 fields. Is their maybe a solution for this?

Posted: Wed Oct 08, 2003 3:22 am
by volka
Let them add their songs in steps of (let's say) five.
Then the form gets submitted and they can enter the next five songs.

Posted: Wed Oct 08, 2003 3:28 am
by Paddy
Or get them to enter how many songs they want to add first and then dynamically create that number of fields. Name then by an array.

Or have a text box and get them to separate the songs by the # or something and then explode the variable into an array before adding it to the database.

Posted: Wed Oct 08, 2003 3:41 am
by wizzard
Or something like this a textfield when they click add it will be added in a listbox or is this not possible. Thanks already for the help.

Posted: Wed Oct 08, 2003 3:45 am
by Paddy
Sure if you add it to a database then you can populate a list box from the database.

Posted: Wed Oct 08, 2003 5:08 am
by wizzard
I will try it but i think have to integrate javascript on it because it has to be on realtime. So when they see the form they can add it into the database but without going away from the form?

Posted: Wed Oct 08, 2003 5:38 am
by Paddy
As far as I know you can't add to mysql from js. Why don't you make the form action to the same page? That way you can insert the data then reload the form with a select statement.

Posted: Wed Oct 08, 2003 5:45 am
by wizzard
Ok thanks, i will fix it like this.