It is currently Fri Dec 06, 2024 11:52 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to get audio to play in a table using PHP and MySQL
PostPosted: Tue Jun 07, 2022 12:09 pm 
Newbie
Newbie

Joined: Fri Mar 25, 2022 5:51 am
Posts: 6
I need to build a digital dictionary with with audio files associated with each word. I currently have a table stored in my MySQL database with with various data columns: words, parts of speech, phonetic transcriptions, and absolute paths that lead to audio files stored on the disk.

I would like to be able to query all the data in the table and get it all to display in a table on my webpage. The problem I'm having is that with the omegle.2yu.co code below, my column of file paths displays as text, not as audio files.

<?php
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}

mysqli_close($conn);
?>
Any suggestions how to get audio in my table omeglz cells?


Last edited by Stan654 on Wed Jul 06, 2022 10:29 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to get audio to play in a table using PHP and MySQL
PostPosted: Wed Jun 08, 2022 4:26 am 
Getting Started
Getting Started

Joined: Wed May 26, 2021 3:14 pm
Posts: 52
Hello,

Please note that this is a forum for our hosting and in general we do not offer web developing services or have the knowledge to answer most of the questions on this matter. You might find more information in web developers' forums instead. Thank you for your understanding.

Best Regards,
Damon Felix
ModeratorsTeam
Freehostia.com

_________________
Damon Felix
ModeratorsTeam
Freehostia.com


Top
 Profile  
 
 Post subject: Re: How to get audio to play in a table using PHP and MySQL
PostPosted: Mon Jul 04, 2022 5:59 am 
Newbie
Newbie

Joined: Mon May 30, 2022 12:28 pm
Posts: 4
Your <div class="nav> element is above your <audio> element.

You can see this easily by adding background: black to .nav in your styles - you will see that the audio controls disappear.

You can fix this in several ways, including adding margin-top to push your content below your header, or adding z-index to your <audio> element to raise it above the header elements. Then you will be able to click the Play button and it will work. (I tested this in the Chrome DevTools.)

However, it looks like your header has other design issues (make your window smaller for one example of how it breaks), so you probably want to make other changes to the header design too.


Top
 Profile  
 
 Post subject: Re: How to get audio to play in a table using PHP and MySQL
PostPosted: Wed Jul 06, 2022 7:41 am 
Newbie
Newbie

Joined: Sat Feb 19, 2022 6:24 am
Posts: 6
he answer was right in my face the whole time. Because I was already in a foreach loop for a query that included the joined images table I didn't have to query a second time. I already had the code that checked for an 'm' for mp3. I just had to echo out the controls for audio object with the $posts['image'] there to grab the audio from my database.

elseif (!empty($post['ID']) && ($post['type']== 'm')) {
echo '<audio controls>';
echo '<source
src="data:audio/mp3;base64,'.base64_encode($post['image']).'"‌​>';
echo '</audio>';
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011