>Blink 182
>---------
>
>Whats my age again?                Guitar    Bass    Drum    Lyrics    Buy
>at Amazon.
>Dammit                                    Guitar    Bass    Drum    Lyrics
>Buy at Amazon.
>MnMs                                     Guitar    Bass    Drum    Lyrics
>Buy at Amazon.
>
>Now I know this would be simpler if I had them in different tables, but I
>have my reasons why I dont.
>Here is the setup of the table for storing tabs/lyrics..
>
>CREATE TABLE `resources` (
>`id` INT NOT NULL AUTO_INCREMENT,
>`type` TEXT NOT NULL,
>`title` VARCHAR(100) NOT NULL,
>`content` TEXT NOT NULL,
>`user_id` INT NOT NULL,
>`rating` INT DEFAULT '5' NOT NULL,
>`views` INT DEFAULT '0' NOT NULL,
>`date` TIMESTAMP NOT NULL,
>`artist_id` TEXT,
>`amazon` TEXT,
>INDEX (`id`),
>UNIQUE (`id`)
>);

Is 'type' filled in with one of 'Guitar', 'Bass', 'Drum', 'Lyrics' ???

If so, you could do this:

create table types(type_id, type text not null);
insert into types(type) values('Guitar');
insert into types(type) values('Bass');
insert into types(type) values('Drum');

You could then do:

select blah from resources left outer join types on resources.type =
types.type
where artist_id = 'Blink 182'
order by title, type_id

Then your rows will just naturally "fill" the table.

Or, if you could live with the order being: 'Bass', 'Drum', 'Guitar',
'Lyrics' instead, you could use the table you have and do:

select blah from resources order by type where artist_id = 'Blink 182'
order by title

Then, in your PHP script, you'll have to do:

$columns = array('Bass', 'Drum', 'Guitar', 'Lyrics');
$column = 0;
$row = mysql_fetch_row(...);
while($row){
  if ($row['type'] == $columns[$column % count($columns)]){
    echo "<A HREF blah blabh blah";
    $row = mysql_fetch_row(...);
  }
  $column++;
}

The technique here is to increase your $column so you know where to put the
data, and to *ONLY* output a for and fetch a new row when you are in the
correct column for that tablature.

-- 
Like Music?  http://l-i-e.com/artists.htm
I'm looking for a PRO QUALITY two-input sound card supported by Linux (any
major distro).  Need to record live events (mixed already) to stereo
CD-quality.  Soundcard Recommendations?
Software to handle the recording? Don't need fancy mixer stuff.  Zero (0)
post-production time.  Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo
audio-to-disk.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to