[英]PHP- Display data in textarea
My goal is to display all emails inside a text area. 我的目标是在文本区域内显示所有电子邮件。
<?php
$q = "SELECT * FROM `Clients`";
$userData = mysql_query($q);
while($user = mysql_fetch_assoc($userData)){
echo $user['Email'];
}
?>
it should echo all info into here: 它应该在这里回显所有信息:
<input type="text" name="text" >
I get the information fine from the DB, but im not sure how to echo the ALL the data into a SINGLE text field.. 我从数据库中获得了很好的信息,但是我不确定如何将所有数据回显到单个文本字段中。
PHP Code PHP代码
$userData = mysql_query($q);
$userEmails = array();
while($user = mysql_fetch_assoc($userData)){
$userEmails[] = $user['Email'];
}
HTML (example with a comma separated email string) HTML(带有逗号分隔的电子邮件字符串的示例)
<input type="text" value="<?php echo implode(', ', $userEmails); ?>" />
You need to do in following manner:- 您需要按照以下方式进行:
<?php
$q = "SELECT * FROM `Clients`";
$userData = mysql_query($q);
$email = array(); // create an array
while($user = mysql_fetch_assoc($userData)){
$email[] = $user['Email']; // assign each email to that array
}
?>
<textarea><?php echo implode(','$email);?></textarea> // implode the array by `,` now all emails will show wiith `,` seperation.
Note:- this is the way how you need to do. 注意:这是您需要做的方式。 Checking variables and do the necessary changes is on you.
检查变量并进行必要的更改就在您身上。 thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.