I want to create an accordion MENU (Don't know if it will be created using divs
or <ul>
) and when I click on a submenu I need to execute a mysql query
.
I mean, when I click on the submenu I need to update the data/content of the table that is beside the menu. I'm not sure how to do it and/or if its better to use Ajax
or PHP
, I'm new to both.
All I could do so far is to create the accordion menu using divs.
<?php
include("conexao.php");
function loadTable(){
$pdo = conectar();
$query_select = $pdo->prepare("SELECT prof.nome AS PROFESSOR, disc.nome AS DISCIPLINA, prof.ch AS ch
FROM professor prof
INNER JOIN prof_disc pd ON prof.id = pd.fk_prof
INNER JOIN disciplina disc ON pd.fk_disc = disc.id");
$query_select->execute();
$line = $query_select->fetchAll(PDO::FETCH_OBJ);
foreach($line as $row){
echo "
<h3><span class='arrow-r'></span>".$row->PROFESSOR."</h3>
<div style='display: none;' class=''>
<p>".$row->DISCIPLINA."</p>
</div>
";
}
echo '</table>';
}
?>
We'll have something like:PROFESSOR | DISCIPLINA
Math - | History
Geografia | Physics