I'm generating a menu with list items generated from a foreach
on a select
query.
I'm printing the 'name' of each row. But, I also wanted to store some other data from that row inside variables so when I click on an <li>
I would get those specific vars.
I would like to do this with Javascript so I don't reload the page.
Here's the code I have so far:
$query = "SELECT * FROM credenciais_sensores where ambiente = '1'";
$results = mysqli_query($conn, $query);
<ul class="treeview-menu">
<?php foreach ($results as $result) {
$local = $result['local'];
$local = substr($local,0,7);
echo "<li><a class='post' href='#'>".$local."</a></li>";
}?>
</ul>
How can I achieve this?