Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个音乐网站。我有这个按钮图像,用于将歌曲添加到播放列表。如果用户单击该按钮,它应该将该歌曲详细信息输入到我的播放列表表中。我知道如何使用文本框向数据库提交信息。有人可以帮我写代码吗? 单击图像/按钮的 IF 条件应该是什么?
有两种方法:
1) 使用常规的 HTML 表单。将表单包裹在您的按钮图像周围,在表单中放置一个带有歌曲详细信息的隐藏字段,例如<input type="hidden" name="song" value="Where the streets have no name">,当提交表单时,您将拥有该歌曲的详细信息。如果必须,请使用多个隐藏字段。
<input type="hidden" name="song" value="Where the streets have no name">
2) 稍微复杂一点,但最好使用 Ajax。您可以从图像 id 属性中收集歌曲详细信息,然后将其全部推送到 PHP 页面。