duanren9163 2018-10-26 03:53
浏览 137

如何从数据库中获取数据并使用php中的下拉列表将其显示到标签?

I would like to display the retrieve data from the database into my input area using a dropdown list also generated from the database. The problem is when a run my code the customername input area is disappearing. Can you help me with these?

Dropdown Note: My Dropdown is working I just included it.

<?php
           $connect = mysqli_connect("localhost", "root", "", "xls_db");  
         ?>
             <select name="customercode" id="customercode" class="form-control"> 
             <option value="" > -----------Customer Code----------- </option> 
         <?php
            $dd_res=mysql_query("Select DISTINCT customercode from cr18_cust_listing WHERE Status = 'Active' ");
            while($r=mysql_fetch_row($dd_res))
            { 
               echo "<option value='$r[0]'> $r[0] </option>";
            }
         ?>
            </select>

PHP to display text

<?php
        $connect = mysqli_connect("localhost", "root", "", "xls_db");  
         if(isset($_POST["customercode"]))  
        {  
      if($_POST["customercode"] != '')  
      {  
           $sql = "SELECT * FROM cr18_cust_listing WHERE customercode = '".$_POST["customercode"]."'";  
      }  
      $result = mysqli_query($connect, $sql);  

     while($r = mysqli_fetch_array($result))  
      {  


      ?>
        <div class="form group has-feedback">
            <input class="form-control" type="text" name="accntname" required="required" placeholder="Customer Name" value="<?php echo $r['customername'] ?>"><span class="glyphicon glyphicon-user form-control-feedback"></span><br />
            </div>
<?php }
       }    ?>

Missing Customer Name input Area

Screenshot

  • 写回答

2条回答 默认 最新

  • douyan2002 2018-10-26 04:03
    关注

    try below code You have closed textarea without open it.

    <input class="form-control" name="accntname" required="required" placeholder="Customer Name" value="<?php echo $r['customername'] ?>"><span class="glyphicon glyphicon-user form-control-feedback"></span><br />
    
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?