yami007 Posted September 4, 2008 Share Posted September 4, 2008 hello again.. what do i have to do ?? i hav a table called "singers" in the database CREATE TABLE `singers` ( `id` int(11) NOT NULL auto_increment, `page_id` int(11) NOT NULL, `name` varchar(60) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; and another table called "songs" ... CREATE TABLE `songs` ( `id` int(11) NOT NULL auto_increment, `singer_id` int(11) NOT NULL, `content` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; and the last one called "mp3" CREATE TABLE `mp3` ( `id` int(11) NOT NULL auto_increment, `song_id` int(11) NOT NULL, `source` varchar(100) NOT NULL, `title` varchar(100) NOT NULL, `artist` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; and the file which is supposed to display XML content is "songs.php" which is known in the flash file <?php include("includes/connection.php"); ?> <?php $query = "SELECT * FROM mp3 "; $results = mysql_query($query); echo "<?xml version=\"1.0\"?>\n"; echo "<songs>\n"; while ($line = mysql_fetch_assoc($results)) { echo "<song src=\"{$line["source"]}\"> </song>\n"; } echo "</songs>\n"; ?> now please what do i have to do display to each singer his own songs ? I tried this but nothing displayed ... <?php $query = "SELECT * FROM mp3 WHERE id=" . $song_id ."; ?> Quote Link to comment Share on other sites More sharing options...
vicodin Posted September 4, 2008 Share Posted September 4, 2008 This should do it.... $query = "SELECT * FROM mp3 WHERE id = '$song_id'"; Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted September 4, 2008 Share Posted September 4, 2008 Don't you mean the song_id = '$song_id'? I'm a little confused. Why else do you have that column? Quote Link to comment Share on other sites More sharing options...
burn1337 Posted September 4, 2008 Share Posted September 4, 2008 ken your right I think, it should be songid = $song_id I think lol . but I think the overall problem is the fact that the resorce id is trying to pull the entire table, narrow it down to a single row. before you go trying to display it (could be wrong I normaly don't use while loops). Also I would suggest using single quotes for your array instead of double.. $line['source'] Quote Link to comment Share on other sites More sharing options...
yami007 Posted September 4, 2008 Author Share Posted September 4, 2008 I tried what you said, but the player doesnt display anything... Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 4, 2008 Share Posted September 4, 2008 I don't understand the need for a song table and an mp3 table. Wouldn't a song be the mp3? I guess you could have multiple versions of the song. Anyway, I interpreted the question as to how to show just the songs for a particular singer. based upon the table structure, the following query should get you all of the songs for the identified singer: SELECT * FROM songs JOIN mp3 ON songs.id = mp3.song_id JOIN singers ON songs.singer_id = singers.id WHERE singer.id = '$singer_id' Quote Link to comment Share on other sites More sharing options...
yami007 Posted September 4, 2008 Author Share Posted September 4, 2008 I dont get what you say, how should i do that ?? Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 5, 2008 Share Posted September 5, 2008 I dont get what you say, how should i do that ?? I'm not sure how to anser that. You gave your table structure and stated that you wanted to get the list of songs/mp3s for a particular singer. The query I provided will do that. Was that not what you wanted? I'm guessing you don't understand JOINS. This forum is not an appropriate palce to give a lesson on database joins, but there are plenty of tutorials on the net. Quote Link to comment Share on other sites More sharing options...
yami007 Posted September 6, 2008 Author Share Posted September 6, 2008 man, i never heard of JOIN in database... i may give up doing this but i need it Quote Link to comment Share on other sites More sharing options...
yami007 Posted March 30, 2009 Author Share Posted March 30, 2009 ah man thanks anyway but i forgot to come here after i solved it ^^ well what i did is : flashvars in embed flash and instead of calling songs.php i call songs.php?id=( the id of the selected singer ) and in songs.php i call the songs which have the singer_id = to the id that i get from the url and so it worked very well Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.