Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Php Seperation of Data issue

(139 views • 4 replies)

This topic is 1 page long.

<< < > >>
None

azrag

Reply To Post Reply & Quote

Posted at: 8/30/07 12:12 AM

azrag NEUTRAL LEVEL 13

Sign-Up: 08/26/03

Posts: 1,132

alright I am pulling data from the database using a key variable as my search limitation to get the right data. Here is my problem I want to pull out all the songs made by a particular artist and organize and separate them and put them automatically where the album is. I know this isnt very clear so I will give a quick example (by the way this is a lyrics site)

http://mysite.com/artist.php?id=yellowca rd

ok id = yellowcard this will be used in a mysql query to limit down all the yellowcard songs in the database

Artist ---------------- Album ----------------------- Song
yellowcard / Paper Walls / Fighting
yellowcard / Lights and Sounds / Lights and Sounds
yellowcard / Paper Walls / Light up The Sky

ok above is the results pulled from the database notice the seperate albums now here is what I want to do with this.

(pretend below is a page result organizing the albums with the songs associated with them)
Album Paper Walls
-----------------------------
Light up The Sky
Fighting

Album Lights and Sounds
------------------------------------
Lights and Sounds

Once I get the results how do I seperate them like what I just did all help would be greatly appreciated

ITS OVER 9000!!!!!!!!!!! 8========D !!!!!!!!!!!!!!!! NIGG@H!!!!!!! MOAR RACISM!!!!!!!!!!!!!


None

authorblues

Reply To Post Reply & Quote

Posted at: 8/30/07 12:20 AM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,265

At 8/30/07 12:12 AM, azrag wrote: appreciated

when you call the data, you could always just use "ORDER BY album"

my blog. smash code: 3523-1700-9216 [AUTHR]

BBS Signature

None

DFox

Reply To Post Reply & Quote

Posted at: 8/30/07 12:21 AM

DFox LIGHT LEVEL 30

Sign-Up: 08/09/03

Posts: 9,216

If I understand what you mean, you can do something like this in your SELECT statement:
ORDER BY Album ASC

Then, when you loop through the results, just keep track of what the last album was, and if the current value is different, it means you're up to a new album.


None

azrag

Reply To Post Reply & Quote

Posted at: 8/30/07 12:22 AM

azrag NEUTRAL LEVEL 13

Sign-Up: 08/26/03

Posts: 1,132

well I knew about that but I want it to display the album name and the cover I have stored while listing the songs right next to it. im still searching though for a way

ITS OVER 9000!!!!!!!!!!! 8========D !!!!!!!!!!!!!!!! NIGG@H!!!!!!! MOAR RACISM!!!!!!!!!!!!!


None

elbekko

Reply To Post Reply & Quote

Posted at: 8/30/07 01:53 PM

elbekko EVIL LEVEL 16

Sign-Up: 07/23/04

Posts: 6,306

Use a control var:

$a = '';
while($row = mysql_fetch_assoc($result))
{
if($row['album'] == $a)
echo $row['album'];
// Rest
$a = $row['album'];
}

"My software never has bugs. It just develops random features. " - Unknown

[ PHP: Main | Omigod, a blog ]

BBS Signature

All times are Eastern Daylight Time (GMT -4) | Current Time: 04:50 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!