简体   繁体   English

从表单中获取textarea值

[英]Getting textarea value from form

I'm having an error regarding on getting value from the form of the other page. 我在从其他页面的形式获取价值时遇到错误。

Here's the code snippet: 这是代码片段:

<?php

while($row = mysqli_fetch_array($result))
{
    echo "ID: <input type='text' name='id' value='$row[id]'><br/>";
    echo "Date: <input type='text' name='date' value='$row[date]'><br/>";
    echo "Event: <textarea type='text' name='event'><?php echo $row[event]; ?></textarea><br/>";
    echo "Note: <input type='text' name='note' value='$row[note]'><br/>";
}
?>

The form has 2 options, edit and delete . 表单有2个选项, editdelete Getting the textarea's value is working, but unfortunately, it also displays the php code. 获得textarea的值是有效的,但不幸的是,它还显示了php代码。

For example: 例如:
Textarea's value : Welcome Textarea的价值Welcome
How it displays : <?php echo Welcome; ?> 它是如何显示的<?php echo Welcome; ?> <?php echo Welcome; ?>

这样做......

echo "Event: <textarea type='text' name='event'>".$row['event']."</textarea><br/>";

Change 更改

echo "Event: <textarea type='text' name='event'><?php echo $row[event]; ?></textarea><br/>";

to

echo "Event: <textarea type='text' name='event'>".$row['event']."</textarea><br/>";

you use <?php and ?> inside your echo string 你在echo字符串中使用<?php?>

your array key 'event' also needs to be within single qoutes 您的数组键'event'也需要在单个qoutes内

change 更改

echo "Event: <textarea type='text' name='event'><?php echo $row[event]; ?></textarea><br/>";

into

echo "Event: <textarea type='text' name='event'> $row['event'] </textarea><br/>";

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

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