douzen1896 2014-07-21 11:36
浏览 21

选择选项PHP

I am implementing some code but for some reason when I choose an option it retrieves correctly the row I want but I can't select the "Select" to show all the results again.

For example, I have "SELECT", "A", "B". When I choose A or B it shows me the A or B results but when I want it to show all clicking "SELECT" it shows me the last result.

EDIT: And when I choose an option, the option stays "SELECT" and not the one I selected...

The code is:

        <td class="titletable2" >GRUPO<font color="#F25C09">: </font></td>
<td>
    <select name="grupo_id_grupo" id="id_grupo" onchange="document.getElementById('pesquisaform').submit()">
        <option value="-1" 
        <?php if ($_SESSION["filtro"]['id_'] == '-1' || !isset($_SESSION["filtro"]['grupo_id_grupo'])) { echo "selected"; } ?>>
        <?php echo "<option value = '".$grupo['nome']."'";?></option>
        <?php 
            $DB = new DataBase();
            $listagrupos = $DB->select_associative_data("grupo", "*");
            $DB->disconnect();

             foreach ($listagrupos as $grupo){
                echo "<option value = '".$grupo['id_grupo']."'";

                if( isset($_SESSION["filtro"]['id_grupo']) && $_SESSION["filtro"]['id_grupo'] == $grupo['id_grupo']){ echo "selected";};

                echo ">".$grupo['nome']."</option>";
            }
        ?>
    </select>
</td>
  • 写回答

1条回答 默认 最新

  • douji9518 2014-07-21 11:42
    关注
    $DB = new DataBase();
    
                    $listagrupos = $DB->query(SELECT * FROM grupo);
    
                    $DB->disconnect();
    

    i think you need query or queryFunc instead of select_associative_data

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题