Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm creating a web app for a company that sells mp3 sound clips. I have implemented a register, login, payment and admin functions. Within the admin page I have allowed the privileged user to add an mp3 which the name will be added to a mysql database table, the actual file uploaded to an FTP server and the part I'm having problems with is displaying the newly uploaded sound clip to the corresponding page on the site. So basically every time the 'upload' button is pressed then I need a block of HTML code to be written to one of the pages on the site.

I would appreciate any guidance on where to start. I've been reading up on DOM but I don't think it's the right way to go about it. Thanks in advance

share|improve this question
    
normally the page would be create dynamicly based on what's in the db –  Dagon Jul 14 '13 at 20:53
add comment

1 Answer

You shouldn't try to append a content to the HTML file. What will you do when your user removes the MP3 ? Remove the HTML content ? Heavy process ^^

Where you basically use your HTML file, use a PHP script which reads entries from your database. Something like...

$db = new PDO(/* database settings */);
$query = $db->query("SELECT * FROM musics");
while($result = $query->fetch(PDO::FETCH_OBJ))
{
    echo $result->song_name . " by " . $result->artist;
}

This will list your songs and give that kind of output :

My Little Song by Soroush Shamsfard.
My Favourite Song by Soroush Shamsfard.

Some information about reading data from a database :

http://www.electrictoolbox.com/php-pdo-bound-placeholders/

share|improve this answer
    
Thanks John sorted it! –  FootsieNG Jul 17 '13 at 23:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.