使数据库输出显示在输入字段中

时间:2015-07-18 05:33:17

标签: php input

我希望能够从我的数据库中获取输出的数据以显示在输入框中,以便我以后能够更新数据。我试图将输出回显到输入字段,但它只显示在我的输入字段下。我怎么能这样做?

<?php
$con = mysqli_connect("localhost", "root", "", "db");
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
$stmt = mysqli_query($con,"SELECT * FROM user_players");
while($row = mysqli_fetch_array($stmt)) {
    $player1 = $row['player1'];
    $player2 = $row['player2'];
    $player3 = $row['player3'];
    $player4 = $row['player4'];
    $player5 = $row['player5'];
    $player6 = $row['player6'];
?>
    <div class="draftResultsWrap">
        <div class="inline">
        <?php echo "<div>" . $row['firstname'] . " " . $row['lastname'] . "</div>"; ?>
        </div>
        <input class="draftBorder"><?php echo $player1; ?></input>

1 个答案:

答案 0 :(得分:4)

在html输入值内的回显php值

<input class="draftBorder" value='<?php echo $player1; ?>'/>