简体   繁体   English

如何使用PHP填充SQL Server中的HTML表单字段

[英]How to fill HTML form fields from SQL server with PHP

I am trying to get data and dump them to my HTML form from the SQL server. 我正在尝试获取数据并将其从SQL Server转储到我的HTML表单中。 For example I type a name to my HTML form and I want to dump all the information of that name from the database ( last name, email etc.). 例如,我在HTML表单中键入一个名称,然后想从数据库中转储该名称的所有信息(姓氏,电子邮件等)。

I created the form and a simple PHP connector that finds the name and the other information for that name ( last name). 我创建了表单和一个简单的PHP连接器,用于查找名称和该名称的其他信息(姓氏)。 I can echo it on PHP file but I want to show it on the input last name as a value so I can use it for JavaScript purpose. 我可以在PHP文件上回显它,但我想在输入的姓氏上将其显示为值,以便可以将其用于JavaScript。

<form class="form-inline">

  <table class="table table-condensed">
    <tbody>
      <tr>


        <td><label for="lastname">Last Name:</label> </td>
        <td><input type="name" class="form-control" id="lastname" placeholder="last name"></td>
        <td><label for="firstname">First Name:</label> </td>
        <td><input type="name" class="form-control" id="name" placeholder="first name"></td>


      </tr>

    </tbody>
  </table>
</form>

Add it as the value for the HTML input. 将其添加为HTML输入的

<form ...>
    ...
    <input type="text" name="last_name" value="<?php echo $row->last_name; ?>">
    ...
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM