如何在更新页面上获取下拉值

时间:2018-04-10 17:51:22

标签: php mysql

我正在创建一个IMS系统。在订单页面上,我选择了一个下拉列表,当我从下拉列表中选择任何选项时,它完美地工作,但当它重定向到更新页面下拉时,归档数据将变为空白。如果有人知道解决方案,请帮助。以下是我的create.php

代码
<select class="form-control select_group party" data-row-id="row_1"
        id="party_1" name="name" style="width:100%;" required>
  <option value=""></option>
  <?php
      $dbc = mysqli_connect('localhost', 'root', '', 'stock')
               or die('Error connecting to MySQL server.');
      $query = "SELECT * FROM partys";
      $result = mysqli_query($dbc, $query);
      while ($row = mysqli_fetch_array($result)) {
  ?>
  <option value="<?php echo $row['name'] ?>">
      <?php echo $row['name'] ?
  </option>
  <?php } ?>
</select>

适用于update.php

<select class="form-control select_group party" data-row-id="row_1" id="party_1" 
        name="name" style="width:100%;" required>
  <option value=""></option>
  <?php
      $dbc = mysqli_connect('localhost', 'root', '', 'stock')
               or die('Error connecting to MySQL server.');
      $query = "SELECT * FROM partys";
      $result = mysqli_query($dbc, $query);
      while ($row = mysqli_fetch_array($result)) {
  ?>
  <option <?php if (!empty($name) && $name == $row['name']) echo 'selected = "selected"'; ?> value="<?php echo $row['name'];?>"><?php echo $row['party_id'];?>
  </option>
  <?php } ?>
</select>

0 个答案:

没有答案