使用组合框在mysql和php中插入值

7qhs6swi  于 2021-06-23  发布在  Mysql
关注(0)|答案(1)|浏览(339)

所以,我想在mysql中插入值,但是使用一个组合框。我已经尝试了一些代码,但它不起作用。要插入正常数据,我有以下代码:

  1. <input name="password" type="text" placeholder="Password"
  2. value="<?php echo !empty($password) ? $password : ''; ?>">

我想创建一个“ user_type “字段(如 adm , developer , normal_user ),但作为 ComboBox .
数据库名称: bsh 表名: customers 我不知道怎么做,请问我怎么做?

jtoj6r0c

jtoj6r0c1#

  1. <select name="user_type">
  2. <option value="admin" <?php echo !empty($user_type) && $user_type == 'admin' ? 'selected' : ''; ?> >Admin</option>
  3. <option value="developer" <?php echo !empty($user_type) && $user_type == 'developer' ? 'selected' : ''; ?>>
  4. Developer
  5. </option>
  6. <option value="normal_user" <?php echo !empty($user_type) && $user_type == 'normal_user' ? 'selected' : ''; ?>>
  7. Normal User
  8. </option>
  9. </select>

当您提交表单时,您将获得带有nam$\u post['user\u type']的user\u type值。也许对你有帮助

相关问题