Im trying to update the src from the audio tag if i click on a button. So i need to translate the $muziek variable to Jquery
View:
<?php
    foreach ($muziek as $ms)
    {
        if ($ms->id == 2) {
            echo '<audio id="player" controls src="data:audio/mpeg;base64,' . base64_encode($ms->audio) . '">';
            echo '</audio>';
        }
    }
    foreach ($muziek as $ms)
    {
        echo '<br>';
        echo '<input id="'.$ms->id.'" type="button" value="' . $ms->naam . '" class = "btn btn-login login-formcontrol"/>';
    }
?>
</div>
<script>
    $("input").click(function () {
       var test = $(this).attr("id");
       console.log(test);
       //Here needs to be the foreach muziek       
    });
</script>
Muziek variable: This is how i fill the music variable
function getAllMuziek()
{
    $query = $this->db->get('muziek');
    $muziek = $query->result();
    return $muziek;
}
Does someone has an idea or show me how this can be done?
 
     
     
    