I have some data that I get from MySQL and I want to put it into a vue.js data property so that I can iterate over it with v-for.
What format should I choose (json or array?) and what do I have to do so that the data is available in vue.js?
<?php
$sql = 'SELECT * FROM kurse;';
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0) {
$termineObj = new stdClass();
while ($row = mysqli_fetch_assoc($result)) {
echo $termineObj->datum = $row['datum'];
$termineObj->uhrzeitvon = $row['uhrzeitvon'];
$termineObj->uhrzeitbis = $row['uhrzeitbis'];
$termineObj->freieplaetze = $row['freieplaetze'];
$termine = json_encode($termineObj);
echo $termine;
}
}
?>
...
<script>var app4 = new Vue({
el: '#app-4',
data: {
termine: termine,
},
delimiters: ["((","))"],
methods: {
flipstate:function(){
console.log('flipped');
}
},
})</script>