general php quastion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

general php quastion

Post by mellowman »

ok so this is still in concept mode so i don't have a example right now.But here it goes.

So im trying to make a mp3 site that can add music to a to mp3 player just a simple add song button but im using a database to pull in the location of the mp3 to load the song.But the problem im having is not that part but its the part when it trys to add it to the mp3 player it dosnt know wheather to put it in the first slot or second slot.because how would it know if slot one or 2 is taken.

And i heard from a friend that an array would be able to solve my answer but i tryed looking into it and i dont know how it would solve the problem because and array doesn't fix a "ifset" problem.nore does the ifset function :[
frao_0
Forum Commoner
Posts: 27
Joined: Sat Aug 08, 2009 3:52 am
Location: Toulouse, France

Re: general php quastion

Post by frao_0 »

yes, an array does have an 'ifset' function!

Code: Select all

if(isset($array[$key]))
Yet, for your project, people usually go like Winamp or iTunes, which means having a XML representation of a database. Have you consider Flex for this project? Do you want to do something like playlist.com?
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: general php quastion

Post by mellowman »

yes similar to playlist.com but i would have many..improvements in my eyes....But ive never seen flex before i looked it up and its cool but it seems easyer to just structure "playlists" in a database instead of a xml file so that u have less files 1 and 2 easyer to save the data by querying a database table that has all the songs that u have saved to the playlist. :D

But if u have another suggestions on how to layout this wheather xml or database please explain y..it would help alot :D
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: general php quastion

Post by onion2k »

mellowman wrote:So im trying to make a mp3 site that can add music to a to mp3 player just a simple add song button
Can't be done with an iPod. That's going to be a problem.
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: general php quastion

Post by mellowman »

onion2k wrote:
mellowman wrote:So im trying to make a mp3 site that can add music to a to mp3 player just a simple add song button
Can't be done with an iPod. That's going to be a problem.
there wont be any point in an ipod there will be a archive of music to pick from..Like any song...And u can share your playlist with others :]...And i hope u know this isnt a program its a website acting as a site for your music u pick from and share.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: general php quastion

Post by onion2k »

Err.. so what does "that can add music to a to mp3 player" mean then? Do you mean "MP3 player" in the sense of a Flash application that plays MP3s? Or an MP3 player like an iPod?
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: general php quastion

Post by mellowman »

As in a flash mp3 player that plays music u picked from the site.
frao_0
Forum Commoner
Posts: 27
Joined: Sat Aug 08, 2009 3:52 am
Location: Toulouse, France

Re: general php quastion

Post by frao_0 »

Ok, can you rephrase your question then? What do you mean by "slot"?
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: general php quastion

Post by mellowman »

ok so the way i set up the mp3 player is in 2 versions

1.non registered users<--uses sessions to store data
2.registered user<---pulls from database

Now for the question about the slot problem.The way im doing it for the first version is with sessions and having names like

Session['song'1']<---im using lamins terms
Session['song'2']
Session['song'3']
Session['song'4']
Session['song'5']

But when i submit the song how does it check if session 1 or 2 is taken and to put it into the 3rd session...

Code: Select all

   if(isset($array[$key]))
And could someone explain this to me..never really understood the hole array concept
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: general php quastion

Post by mellowman »

...fixed my problem alredy:]

heres the fix if any needs it :]

Code: Select all

 
<?php 
session_start();
function addsong ($songname)
{
  if (array_key_exists("songs", $_SESSION)) 
  {
    $songs = $_SESSION['songs'];
  }
  else
  {
    $songs=array();
  }
  
  array_push($songs, $songname);
  $_SESSION['songs']=$songs;
 
  
}
  
  
  addsong ($_POST['songname']);
   $songs = $_SESSION['songs'];
  
  
?> 
 
Post Reply