I am working on a menu system for a LMS which has tabs across the top for each class and then the module menu opens down the side based on the class which is selected. I am very close to making it dynamic from the DB but have one glitch that I have spent a couple days on. I have read everything I can find but I am stuck so hoping someone here has the answer. It seems to me that the most efficient way would be to store the active tab in the Alpine.store and then retrieve it within the class which queries the DB. I can retieve the data from the store in the form of x-text but and it echos out fine but I can't get the PDO query to recognise it. After all the searching and testing I have come to the conclusion that it must have to do with the order that the content is processed in the DOM so that the x-text is happening after the PDO query but I have not found a way to force it to run first or a different way to retrieve the store data in a variable that PHP will use. Any help is greatly appreciated!
$parent='\<container x-text="$store.nav.activeTab"\>\</container\>';
$parent=array($parent);
print_r($parent);
$sql = "SELECT * FROM nav WHERE parent LIKE ? && type = 'ClassMod'";
$stmt = $this->connect()->prepare($sql);
$stmt->execute($parent);
I have tried using jquery/AJAX, plain JS, and every related tutorial I can find on Alpine. I just want a way to retrieve Alpine.store data and use at as a PHP variable which I can use in a query. I can easily get the Alpine.store data printed to the screen, it just won't work in a query.