Need help with Fields & Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Need help with Fields & Database

Post 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
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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.
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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.
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Post 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.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Sure if you add it to a database then you can populate a list box from the database.
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Post 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?
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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.
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Post by wizzard »

Ok thanks, i will fix it like this.
Post Reply