好的,为了让一切都清楚我会尽我所能解释一切,并包含图像。这可能会是一个相当长的问题,但我只想把一切都弄清楚。使用动态下拉列表从MySQL数据库中加载数据到textarea
嗯,我curently有一个 “文本框”(TinyMCE的AJAX文件管理器),这是从一个文本文件显示HTML这样的:
这是代码到该ATM:
Bericht:</td><td align="left"><textarea name="content" cols="50" rows="15"><?php echo "$show"?></textarea></td></tr>
和:
<?php
if (file_exists("prwyswig.txt")){
$show = file_get_contents('prwysiwyg.txt');
}
else{
$show = file_get_contents('tabel.txt');
}
?>
我想要的是不再使用TEXTFILES但我想选择哪个存储在我的HTML代码SQL数据库。我做了一个动态的下拉列表,其中包括“通讯”的名称。
所以我想要的是从下拉列表中选择一个通讯,然后加载属于该标题的html到textarea。我自己尝试过几件事,但我无法弄清楚如何管理这件事。
我是否必须写另一个查询? 我是否必须以另一种形式放置dorpdown列表才能使用提交按钮加载textarea中的数据?
我会在下面发布其余代码和我的数据库表结构,因为您可能需要它们^^如果您有任何其他问题,只需在评论中询问他们,任何帮助都会很棒!
注: 我知道我不应该使用mysql_ *但在这里不是问题。我稍后将改为PDO!
连接到DB +查询来选择正确的数据:
<?php
mysql_connect('localhost','root','root');
mysql_select_db('NAW') or die (mysql_error());
$strSQL = "SELECT Content, Titel FROM NAW.Mail";
$sql_result = mysql_query($strSQL);
?>
动态下拉列表:
<td valign=top>Nieuwsbrief:</td>
<td>
<?php
echo "<select name=\"show\">";
echo "<option size =30 selected>Select</option>";
if(mysql_num_rows($sql_result))
{
while($row = mysql_fetch_assoc($sql_result))
{
echo "<option>$row[Titel]</option>";
}
}
else {
echo "<option>No Names Present</option>";
}
?>
数据库表:
ID Content Datum Titel
1 (lots of encoded html) 18-03-13 test
2 (lots of encoded html) 18-03-13 test2
4 (lots of encoded html) 18-03-13 alles weer testen
5 (lots of encoded html) 20-03-13 testje
6 (lots of encoded html) 21-03-13 Statusupdate week 6
编码和解码HTML? – hjpotter92 2013-03-26 10:46:14
[请不要在新代码中使用'mysql_ *'函数](http://stackoverflow.com/q/12859942/1190388)。他们不再被维护,并[正式弃用](https://wiki.php.net/rfc/mysql_deprecation)。看到红色框?改为了解准备好的语句,然后使用[tag:PDO]或[tag:MySQLi]。 – hjpotter92 2013-03-26 10:47:15
ment编码^^,我知道我不应该使用mysql_ *,看看我的笔记.. – Daanvn 2013-03-26 10:48:08