|
Posted by Andreas Edin on 11/05/05 00:32
Jim Hernandez wrote:
> I'm setting up a database for albums and I've decided to break the
> tracklist down track by track in the table, i.e., albumkey (primary)
> atitle
> aartist
> alabel
> track1
> track2
> track3
> track4... on through track 30.
> I want to call the tracks via php form the database and put them into
> a sidebar on a webpage. Say the db has room for 30 as mine does but
> the album only has 14 tracks, how do I communicate to sql to pull
> until the tracks are null and stop.
>
> Thanks for any help or advice
In this case the easiest way is to create two table's.
One with the album and the other one with the correspondent tracks.
Example:
Table1:
id <--- this field is the uniqe field
album
atitle
artist
alabel
Table2:
id ---> is the same as the album id
---> but in this table it's not a uniqe value, it's an integer
trackname
For each track you insert a new record in table 2.
Then when you want to create an output från this you just makes
two itterations. The first one is on table1, where you can sort it as
you like by albumname, title or label.
For each record in table1 you select all with the same correspondent
number in table2.
I hope this gave you some hint where to start.
Andreas Edin, Sweden
--
Navigation:
[Reply to this message]
|