dqbhdsec59405 2013-07-14 20:48
浏览 225

创建动态HTML。 操作完成后自动将HTML写入网页

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

  • 写回答

1条回答 默认 最新

  • dreamevil0002 2013-07-14 20:52
    关注

    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/

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料