I will create a website in that website admin upload some audio files in the server everything is work perfect but I was uploaded a PHP file in that file I will fetch all the data (Name of file and URL of that file) from the database but I don't know how I can put that data into my HTML code. In HTML when the user clicks the name then URL should load and play music.
<?php
define('DB_HOST','localhost');
define('DB_USERNAME','Root');
define('DB_PASSWORD','');
define('DB_NAME','audiofiles');
//connecting to the db
$con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or
die("Unable to connect");
//sql query
$sql = "SELECT * FROM audio";
//getting result on execution the sql query
$result = mysqli_query($con,$sql);
//response array
$response = array();
$response['audio'] = array();
//traversing through all the rows
while($row =mysqli_fetch_array($result)){
$temp = array();
$temp['id'] = $row['id'];
$temp['name'] = $row['name'];
$temp['url'] = $row['url'];
array_push($response['audio'],$temp);
}
This is my PHP of fetching audio files from the database. I want some help to display that audio file in the HTML page and also play that files. I want to do that PHP file should grab that name and link of the audio file which will work perfectly now I want HTML to embed name and the link as the src.