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/

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)