Jump to content

[SOLVED] help with mp3 player and php


yami007

Recommended Posts

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 .";

?>

Link to comment
Share on other sites

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']

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 6 months later...

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.