dongpu42006096 2016-03-22 04:24
浏览 78

我如何使用php和mysql上传音乐

I have created a table which contains my music information and album art. I've been using Mysql and PHP to create the table and implement the images. I don't understand how I would upload my music onto this table as well though? Could someone help?

I need my music to show and play in the play column.

As you can see, on the far right is the play column and the names of the mp3 files are in the play column as well

And this is where my audio files are

And here is my coding:

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
     border: 1px solid black;
}
</style>
</head>
<body>

<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "jukebox";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
} 


$sql = "SELECT * FROM Music";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
     echo "<table>

     <tr>

     <th>Artist</th>
     <th>Title</th>
     <th>Album</th>
     <th>Albumcover</th>
     <th>Play</th>
     </tr>";


// output data of each row
     while($row = $result->fetch_assoc()) {

         echo 

         "<tr>

         <td>" . $row["Artist"]. "</td>
         <td>" . $row["Title"]. "</td>
         <td>" . $row["Album"]. "</td>
         <td><img src='/jukebox/img/" . $row["Albumcover"] ."' alt=".$row["Albumcover"]."></td>
         <td>" . $row["Play"]  . "></td>



         </tr>";
     }
     echo "</table>";



} else {
     echo "0 results";
}



?>  


</body>
</html>
  • 写回答

1条回答 默认 最新

  • dsx58940 2016-03-22 08:29
    关注

    try something like this

    echo "<tr>
                <td>" . $row["Artist"]. "</td>
                <td>" . $row["Title"]. "</td>
                <td>" . $row["Album"]. "</td>
                <td><img src='/jukebox/img/" . $row["Albumcover"] ."' alt=".$row["Albumcover"]."></td>
                <td>
                   <audio controls>
                      <source src='pathToAudioFile.mp3' type=\"audio/mpeg\">
                    Your browser does not support the audio element.
                    </audio>
                </td>
             </tr>";
    

    Also make sure that the audio file permission is set properly

    评论

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析