Hi:
I am building a lyric page, but i encounter some problems
I am able to make the loop for all the artist name.
http://www.bt-zone.biz/bbmak/allartist.php
but I want to make a page that lists all artist names, and then when I click the artist name, a list of the song titles come up. I want to know how to I make that?
Here is my table structure
CREATE TABLE artists (
artist_id INT NOT NULL AUTO_INCREMENT,
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL,
PRIMARY KEY(artist_id)
);
CREATE TABLE lyrics (
lyric_id INT NOT NULL AUTO_INCREMENT,
artist_id INT NOT NULL,
song_title VARCHAR(30) NOT NULL,
lyric TEXT NOT NULL,
PRIMARY KEY(lyric_id),
INDEX(artist_id)
);
here is the show.php code
<?
//connect to db and all that stuff
$artist = $_GET['artist_id'];
$sql = mysql_query("SELECT * FROM artist WHERE artist_id='".$artist."'");
$fetch = mysql_fetch_array($sql);
//display the artist name
echo "Artist: {$fetch['firstname']} {$fetch['lastname']}<br><br>";
$sql = mysql_query("SELECT song_title FROM lyric WHERE artist_id='".$artist."'");
//show all of the artist's songs
while($fetch = mysql_fetch_array($sql))
echo "<a href=\"lyric.php?lyric_id={$fetch['song_title']}\">{$fetch['song_title']}<br>";
?>
here is my lyric.php <-something wrong here, and i can not show anything, and I don't know what is wrong
<?
//connect to db and all that stuff
$lyric_id = $_GET['song_title'];
$sql = mysql_query("SELECT * FROM lyric WHERE song_title='".$lyric_id."'");
$fetch = mysql_fetch_array($sql);
echo "Song Title: {$fetch['song_title']}<br>";
$sql = mysql_query("SELECT lyric FROM lyric WHERE song_title='".$lyric_id."'");
$fetch = mysql_fetch_array($sql);
//show all of the artist's songs
echo "{$fetch['lyric']}";
?>