1

I'm looking to be able to get my outputted data from my database to appear into an input box, so that I have the ability to update the data later on. I am trying to echo the output into the input field, but it just displays under my input field. How could I do this?

<?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
  • 3
    <input value="<?=$player1?>" Commented Jul 18, 2015 at 5:34

1 Answer 1

4

Echo php value inside html input value

<input class="draftBorder" value='<?php echo $player1; ?>'/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.