Jump to content

PHP file write question PLEASE HELP!


robmarston

Recommended Posts

Is it possible to use PHP to add/remove text from a flat file?

 

Basically, what I'm attempting to do is have users click to add/remove (manage) songs from a dynamically generated XML playlist.

I've used the file write command to generate a successful XML playlist file, but every time the form data is submitted, it overwrites the entire file. 

I want the user to be able to not only add songs, but remove old ones as well.

 

I've considered simply adding or removing songs from a database table, but how then would I generate the playlist from database information?

 

PLEASE HELP!

 

Please send help to: robmarston@hotmail.com -

 

Thank you!

Link to comment
Share on other sites

Actually, depending upon how expansive your information is going to become, you might consider using a database anyway.  This seems like the kind of application that would need one...that way you could relationally store information about a particular item's author, genre, whatever...As for generating a playlist out of database information...You could technically query your database, and then output the queried data in to a flat file for use as a playlist:

 

$q = "SELECT * FROM tbl_songs";

 

$q_result=mysql_query($q);

 

 

//Open or create flat playlist file.

$f_handle=fopen("playlist", "w+");

 

 

 

while ($q_array=mysql_fetch_assoc($q_result))

 

            {

                //Feed the contents of the SQL query in to variable

                $content=$content.q_array[songName];

 

 

              }

 

//Write the final contents out to the flat file.

fwrite($f_handle,$contents);

 

 

Sorry if I'm misunderstanding you here!

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.