doujingya1166 2014-03-14 10:06
浏览 193
已采纳

在SELECT里面循环

I am new to php and html, so I need some help with a problem: I am trying to make a form where you can select from a dropbox, but thae data from the dropbox should be retrieved from a sql database. If I save the code bellow as php, the dropbox is created and retrieves the data from sql, but then the submit button (together with everything else I put after the while loop) disappeares. If I save it as a html file, the form and submit button works, but it doesn't retrieve any data from sql database.

Thanks

<form action="Techniques.php" method="post">
        <p>Which Disease?
        <select name="disease" >
            <option value="" >--Select--</option>
        <?php
          require_once("dbconnect.php");

          $sql = "SELECT * FROM diseases";
          $result = mysql_query($sql)or die (mysql_error());
                while($row = mysql_fetch_array($result) or die (mysql_error()))
                {
        ?>
                 <option value ="<?php echo($row['Disease']);?>"><?php echo($row['Disease']);?></option>
        <?php
                }
        ?>        

        </select>
        </p>
        <input type="submit" value="Copmlete"/>
    </form>
  • 写回答

3条回答 默认 最新

  • doukuai3822 2014-03-14 10:28
    关注

    If you save your file as a .html file, the PHP code won't be executed.

    The .html extension you see in many websites on files that contain PHP is obtained through URL rewriting.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解