php – How to echo $row[“Text’] to a TextField – Education Career Blog

Using PHP I am able to query MySQL database and see the results echo using:

echo $row'Text';

I would like the information to load into TextField myAnswer instead. Can anyone help?



Like this

<input type="text" name="myAnswer" value="<?php echo htmlspecialchars($row'Text') ?>" />


<textarea name="myAnswer" rows="6" cols="40"><?php echo htmlspecialchars($row'Text') ?></textarea>


None of this seems to work for me. Upon looking further, I found the following: — You can not manipulate text fields like java or C# or as3 but you can echo or print out html tags and text. if you echo your text you will need to space or manipulate using css and html.

So I guess I can’t get the results back from the query in a textbox using PHP and MySQL.

Thanks anyways


Going on assumption from your question, you might try something like:

<input type="textbox" value="<?php echo $row'Text'; ?>" />

If you’re thinking about a textarea control it’d be like this:

<textarea><?php echo $row'Text'; ?></textarea>


<input type="text" name="myAnswer" value="<?php echo $row'Text'; ?>" />


<?php if ($row'Text') {?> 
<textarea><?php echo htmlspecialchars($row'Text'); ?></textarea>
<?php } ?>

if you are displaying in the same page, otherwise you can just leave out the if .. check.

Leave a Comment