i have a json array which looks like this
array(3) { [0]=> array(8) { ["userid"]=> int(1) ["ticketid"]=> int(1) ["betreff"]=> string(13) "VS Code fehlt" ["raum"]=> string(3) "241" ["nachricht"]=> string(33) "Hey mrq, dings funktioniert nicht" ["bilder"]=> string(12) "guckbild.png" ["zustaendige"]=> int(0) ["status"]=> string(5) "Offen" } [1]=> array(8) { ["userid"]=> int(1) ["ticketid"]=> int(2) ["betreff"]=> string(3) "sad" ["raum"]=> string(2) "23" ["nachricht"]=> string(5) "asasd" ["bilder"]=> string(6) "as.png" ["zustaendige"]=> int(0) ["status"]=> string(5) "Offen" } [2]=> array(8) { ["userid"]=> int(1) ["ticketid"]=> int(3) ["betreff"]=> string(6) "MALWIN" ["raum"]=> string(2) "23" ["nachricht"]=> string(7) "BITTGEH" ["bilder"]=> string(6) "as.png" ["zustaendige"]=> int(0) ["status"]=> string(5) "Offen" } }
i am trying to create a list of buttons which has the value of the "betreff" (translated = subject)
This is the loop which i am using right now to create this
for($i = 0; $i<count($json_array); $i++){
echo '<br><button onClick="setTicketValue(' .$json_array[$i]['ticketid'].')">'.$json_array[$i]['betreff'].'</button>';
}
as you can see ive created a function setTicketValue In this function it should only change the value of the $_SESSION['ticketid'] Thats the code:
function setTicketValue($ticketid){
$_SESSION['ticketid'] = $ticketid;
}
When i call the function outside the loop it works, but the buttons with this function doesnt.