如何将列表回显到textarea?

时间:2016-01-08 10:40:20

标签: php html mysql

我正在尝试将列表回显到textarea(允许简单的复制和粘贴),我已经将列表回显为平面html并且它应该出现,但我希望它在里面textarea,这是我到目前为止所做的......

<?php
include (ABSPATH.'/connect_include.php');
$AvDates = "SELECT * FROM DB_Available_Dates";
$AvDates = mysql_query($AvDates) or die(mysql_error());

if(mysql_num_rows($AvDates) > 0){
?>
<input value=
<ul>
<?php
   while ($row_AvDates = mysql_fetch_assoc($AvDates)){ 
?>
      <li><?php echo htmlentities($row_AvDates['Month']).' - '. htmlentities ($row_AvDates['the_days']); ?></li> 
<?php
   }      
?>
</ul> />

<?php
}

?>

这不起作用 - 我怎样才能使这项工作?

1 个答案:

答案 0 :(得分:0)

我想这可能会对你有所帮助:

<textarea>
<?php
$anyVar = "This\nis\na\nstring";
echo $anyVar;
?>
</textarea>

更新:示例演示

<?php 
include (ABSPATH.'/connect_include.php'); 

$AvDates="SELECT * FROM DB_Available_Dates"; 
$AvDates=mysql_query($AvDates) or die(mysql_error()); 
if(mysql_num_rows($AvDates)>0)
{ 
?>
  <textarea>
  <?php 
    while ($row_AvDates=mysql_fetch_assoc($AvDates))
    {
      echo htmlentities($row_AvDates['Month']) . " - " . htmlentities ($row_AvDates['the_days']) . "\n"; 
    }
  ?>
  </textarea>    
<?php 
} 
?>