doulu4316 2015-06-30 12:38
浏览 20

单击菜单更新表数据

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

  • 写回答

2条回答 默认 最新

  • drqj8605 2015-06-30 12:47
    关注

    If you want a new mysql query to be executed when you click on a submenu download jQuery. When you have jQuery use the jQuery .click() function and .post() function.

    Edit:

    Handle the event like this:

    Ps. The jQuery selecting logic is the same as in css.

    $(document).ready(function() 
    {
      $("#subMenuItemId").click(function() 
      {
        //Post action here
      });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值