Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从属选择从数据库中拾取两个字段_Php - Fatal编程技术网

Php 从属选择从数据库中拾取两个字段

Php 从属选择从数据库中拾取两个字段,php,Php,kpi和单位这两个字段是连续注册的,现在在注册我的项目的另一种形式上,我需要从kpi表中查询已注册的kpi,在下一个字段中选择后,我需要根据上面选择的kpi选择单位。 我尝试过使用java脚本,但我只能选择表单中的常量项,而不能选择数据库中的常量项。 这是我的密码 <?php $con = mysql_connect('localhost', 'root', ''); $db = mysql_select_db('b

kpi和单位这两个字段是连续注册的,现在在注册我的项目的另一种形式上,我需要从kpi表中查询已注册的kpi,在下一个字段中选择后,我需要根据上面选择的kpi选择单位。 我尝试过使用java脚本,但我只能选择表单中的常量项,而不能选择数据库中的常量项。 这是我的密码

            <?php
            $con = mysql_connect('localhost', 'root', '');

            $db = mysql_select_db('brn1');
            $query1 = mysql_query("SELECT kpi,units FROM kpi " , $con);

         ?>


              <label>Project kpi</label></td> 

               <td> <select name="kpi" id="kpi" style="width:76%;">

              <?php  

           while($data = mysql_fetch_array($query1)){
             $name=$data['kpi'];
             echo "<option value ='$name'>$name</option>";
            }
                ?>

                   </select></td></tr>
            <tr>
              <td>
                 <?php
             $con = mysql_connect('localhost', 'root', '');

            $db = mysql_select_db('brn1');
            $query2 = mysql_query("SELECT units FROM kpi  " , $con);
             ?>

                <label>Unit of measurement</label></td> 

                <td> <select name="units" id="units" style="width:76%;">
              <?php  

             while($data = mysql_fetch_array($query2)){
             $unit=$data['units'];
              echo "<option value ='$unit'>$unit</option>";
                                                 }
           ?>



              </select></td>
               </tr>
               </table>
                 </form>

            <?php
            $con = mysql_connect('localhost', 'root', '');

            $db = mysql_select_db('brn1');
            $query1 = mysql_query("SELECT kpi,units FROM kpi " , $con);

         ?>


              <label>Project kpi</label></td> 

               <td> <select name="kpi" id="kpi" style="width:76%;">

              <?php  

           while($data = mysql_fetch_array($query1)){
             $name=$data['kpi'];
             echo "<option value ='$name'>$name</option>";
            }
                ?>

                   </select></td></tr>
            <tr>
              <td>
                 <?php
             $con = mysql_connect('localhost', 'root', '');

            $db = mysql_select_db('brn1');
            $query2 = mysql_query("SELECT units FROM kpi  " , $con);
             ?>

                <label>Unit of measurement</label></td> 

                <td> <select name="units" id="units" style="width:76%;">
              <?php  

             while($data = mysql_fetch_array($query2)){
             $unit=$data['units'];
              echo "<option value ='$unit'>$unit</option>";
                                                 }
           ?>



              </select></td>
               </tr>
               </table>
                 </form>

项目kpi

使用jqueryonchange方法将值传递给下一个select feildthemarkup是一团乱!在编辑器中修复并粘贴到此处。然后,您可以全部选择并执行
ctrl-k
或单击“代码示例”按钮。