So I didn't found what I was looking for in last two days.
To be clear I have a table "tracks" in my database. So I can show from "tracks" the "demo" field which is an audio file "URL"..
<?= $tracks['demo']; ?>
I have multiple URLs but then I need to replace the a href
<a href="<?php echo $tracks['demo'];?>"
in a logical way.
In simple terms it's like I want to click on button 1 that loads URL 1 into this a href with the ID, title field from that track.
When you press button 2 you need to load another URL and replace URL 1 with url2.
I tried many ways including JavaScript but it won't work.
Problem now is that when I list 4 items it always loads the latest "URL" I have posted in my source code.
When I echo out <?php echo $tracks['demo]; ?> on all items I can see the correct URLs so the functionality to replace the URL is my issue.
*** I basically want to load many mp3 URLs in a player I made in the footer of my website. It works by hardcoding the URLs in the URL field but this is not what it should be... ***
Code:
<?php while($tracks = mysqli_fetch_assoc($muziek)) : ?>
<div class="col-md-2 viny" id="muziek">
<h4><?= $tracks['title']; ?></h4>
<img src="<?= $tracks['img']; ?>"
alt=" <?= $tracks['title']; ?> />
<p class="artist">Artist: <?= $tracks['artist']; ?></p>
</div>
<?= $tracks['demo'] = $audiourl ; ?>
<button type="button" onclick="play">Play</button>
</div>
<?php endwhile; ?>
***THIS LOOPS PERFECTLY FOR ALL ITEMS TRACKS ARE LISTED PERFECTLY ***
In my player I have
<a href="<?php echo $audiourl;?>" ><?= $tracks['artist']; ?></b> - <?= $tracks['title']; ?></a>
function play(){
I'm not good at JS... And this is my issue because it now loads the latest output from the PHP loop... }