Reputation:
I am trying to get data from my database to appear in a textbox or textarea so that it can be easily edited, ready to be submitted to the database. For some reason the data displays but not in a textarea, and therefore cant be edited. This could be a syntax issue. Can anyone help? Thank you.
My code is:
while($row = mysqli_fetch_array($result))
{
echo "<div id='item'>";
echo "<form action='updateproductmain.php' method='post'";
echo "<textarea rows='5' cols='20' name='quote' wrap='physical'>" . $row['product_name'] . "</textarea>";
echo "<input type='submit' value='Submit'>";
echo "</form>";
echo "</div>";
}
Upvotes: 0
Views: 17395
Reputation: 1
<form action="" method="post" enctype="multipart/form-data">
<table style="border:2px solid black;" >
<tr><td> <input type="text" name="id" value="<?php echo $edit; ?>" style="display:none;"></td><tr></tr>
<tr><td> <input type="text" name="firstname" value="<?php echo $firstname; ?>"></td><tr></tr>
<td> <input type="text" name="lastname" value="<?php echo $lastname; ?>"></td><tr></tr>
<td> <input type="text" name="contact" value="<?php echo $contact; ?>"></td><tr></tr>
<td> <textarea name="address" rows="" cols="" value="<?php echo $address; ?>"></textarea></td><tr></tr>
<tr><td><input type="file" name="image" ></td></tr>
<tr><td><input type="text" name="image" style="display:none;" value="<?php echo $image?>"></td><tr></tr>
<td> <input type="submit" name="update" value="update"></td>
</table>
</form>
Upvotes: 0
Reputation: 91734
Your data probably contains characters that break the html, like <
or >
.
You should escape your data using htmlspecialchars()
:
echo "<textarea rows='5' cols='20' name='quote' wrap='physical'>" . htmlspecialchars($row['product_name']) . "</textarea>";
Upvotes: 0
Reputation: 2741
Missing the end >
on your form tag:
while($row = mysqli_fetch_array($result))
{
echo "<div id='item'>";
echo "<form action='updateproductmain.php' method='post'>";
echo "<textarea rows='5' cols='20' name='quote' wrap='physical'>" . $row['product_name'] . "</textarea>";
echo "<input type='submit' value='Submit'>";
echo "</form>";
echo "</div>";
}
Upvotes: 2