dongzichan2886 2019-08-11 20:32
浏览 35

无法从下拉菜单中获取PHP开关案例中的用户输入

I'm using ajax to take user input in a dropdown menu (so the input would be the chosen alternative) and show some information after a button is clicked. It works, but I want to use a switch case statement in the controller, which is not working.

I have this piece of code to populate the dropdown menu:

<form method="post" action="controleur.php">
 <select name="liste_formations" id="liste_formations" class="form-control">
  <option value="">Choisissez une formation</option>
  <?php 
  while($row = mysqli_fetch_array($result))
  {
     echo '<option value="'.$row["idActivite"].'">'.$row["nom"].'</option>';
  }
  ?>
 </select>
</div>
<div class="col-md-4">
 <input type="submit" name="action" class="btn" id="search" value="Voir informations" />
</form>

And when the user clicks the send button it goes to controller.php where I have:

case "Voir informations":
             $idActivite = $_POST['liste_formations'];
             $query = "SELECT * FROM formation WHERE idActivite = '$idActivite'";
             $result = mysqli_query($db, $query);
             while($row = mysqli_fetch_array($result))
             {
              $data["nombreMaxPart"] = $row["nombreMaxPart"];
              $data["idFormateur"] = $row["idFormateur"];
              $data["prix"] = $row["prix"];
              $data["description"] = $row["description"];
             }

             echo json_encode($data);
        break;

When I try to do that I get the information I want, but in a blank page with the information vector. I actually want to show it in a table.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?