Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



MySQL with PHP help


2 replies to this topic - - - - -

#1 Jose_49

    Neowinian Senior

  • 2,998 posts
  • Joined: 30-July 09

Posted 25 July 2012 - 21:33

Hi guys, I really do not know how to make this logic out.

Imagine I would like to get albums and their respective songs from a database and have them sorted; each one with a hyperlink of different sites so it gets to .

Example:

There's an Album "A" and the songs:

1. "One" (And by clicking I will be redirected to -> http://some_link.com/one?=blahrs)
2. "Two" (And by clicking I will be redirected to -> http://some_link.com/two?=blahrs)
3. "Three" (And by clicking I will be redirected to -> http://totally_diffe...com/one?=blahrs)
4. "Four"....etc...


And there's an album "B" and the songs:
"Track 1" (Same methodology as Album A)
"Track 2"
"Track 3"


I would like to store this info on a MySQL database, and retrieve them using PHP.

How my logic is up to right now:

Create MySQL columns with id, t_id, track, album, link

Where id is the default id mechanism in which the rows will be numbered in the Database.
Where t_id is the track number on the album;
Where track is the track name of the album
Where album is the name of the album
Where link is where I want to redirect to when clicked.


How I think I should proceed (but do not know how to)

Group each row of the table by Album first, in which many tracks will have the same album (I'm lost on how to do this).
Then to each different group, sort them via their t_id (Track number of the current album) (I'm lost on how to do this).
Display the information with their links (Easy part)


I'm planning to display them as follows:



Name goes here


1
Album track #1

Hyperlink #1


2
Album track #2

Hyperlink #2



I did not know how to Google this out....

Furthermore, am I approaching this problem correctly?


Thanks a lot and sorry for the long post.


#2 +Phouchg

    Blackheart

  • 3,755 posts
  • Joined: 28-March 11
  • Location: Krikkit
  • OS: GrumpyOS 6.1.7601 x64

Posted 25 July 2012 - 22:40

Normalization dictates that there should be two tables - tracks (with id, t_id, track, album_id and link), and albums (with columns id and album).

#3 OP Jose_49

    Neowinian Senior

  • 2,998 posts
  • Joined: 30-July 09

Posted 25 July 2012 - 23:58

:o.

That way of thinking destroys mine! Thank you!