Following a basic logic, we do the SQL and return a json
// PHP
$retorno = array();
$sql = $pdo->prepare("SELECT * FROM tabela");
$sql->execute();
$retorno['dados'] = $sql->fetchAll();
die(json_encode($retorno));
Done that, by retrieving the json, we would have something similar to that.
[
{
"Nome": "Rafael Augusto"
},
{
"Nome": "Geo"
}
]
Now we could store the result in a sessionStorage to recover on each page.
sessionStorage.setItem('retorno', JSON.stringify(retornoPHP))
Following more or less this logic, you have your return and can access it from any page. Of course there are other ways to do it, but I’m giving this example.
It is possible with
JS– Rafael Augusto
Thanks Rafael, you can put an example, pf?
– Geo