Textarea text is determined by dropdown menu.
Posted: Thu Jul 09, 2009 3:32 pm
I need to create a textarea and dropdown menu. I need the dropdown menu to determine what text will be displayed in the textarea. Both the dropdown menu and the textarea will be pulling information from a mysql db. If anyone has already created a solution for this could you please post the solution or where i could view the solution as i am unable to find one.
Here is what I have came up with so far. The only thing that shows up in the textarea is the first listed content field in the table.
<?php
$result = @mysql_query("SELECT parent_id, label, id FROM dyn_menu");
print "<select name =\"id\">\n";
while ($row = mysql_fetch_assoc($result)){
$none = 'none';
$id = $row['id'];
$label = $row['label'];
$del = $row['label'];
print "<option value=$id name=sub>$label";
}
print "</select>\n";
print "</p>\n";
$cool = @mysql_query("SELECT content FROM `page` WHERE `label`='$label'");
do
{
$id1 = $row2['id'];
$content = $row2['content'];
}
while($row2 = mysql_fetch_assoc($cool));
echo "<textarea cols=\"80\" rows=\"15\" wrap=\"ON\" name=\"body\">".stripslashes($content)."</textarea><br />\n";
?>
Here is what I have came up with so far. The only thing that shows up in the textarea is the first listed content field in the table.
<?php
$result = @mysql_query("SELECT parent_id, label, id FROM dyn_menu");
print "<select name =\"id\">\n";
while ($row = mysql_fetch_assoc($result)){
$none = 'none';
$id = $row['id'];
$label = $row['label'];
$del = $row['label'];
print "<option value=$id name=sub>$label";
}
print "</select>\n";
print "</p>\n";
$cool = @mysql_query("SELECT content FROM `page` WHERE `label`='$label'");
do
{
$id1 = $row2['id'];
$content = $row2['content'];
}
while($row2 = mysql_fetch_assoc($cool));
echo "<textarea cols=\"80\" rows=\"15\" wrap=\"ON\" name=\"body\">".stripslashes($content)."</textarea><br />\n";
?>