populate a text area
Posted: Fri Sep 05, 2003 11:53 am
I need to populate the text area of a form with data coming out of a mysql database. The code I am using is as under. Kindly help me out figuring whats wrong with it.
<?php
@ $db = mysql_pconnect("localhost", "root", "dbstuff3r");
if(!$db)
{
echo "error could not connect to the database. please try again later";
exit;
}
mysql_select_db("extranet");
$sql = "select file_desc from files where id='$id'";
$result = mysql_query($sql);
if(!$result)
{
echo"Cannot execute query";
}
?>
<html>
<head>
<title>Update Patch Description</title>
</head>
<body>
<?
while($row = mysql_fetch_row($result)) {
echo $row[0];
//the data shows up when I echo it here but does not show up in the textarea
?>
<form name='dupdate' method='post' action="<?php echo $_SERVER["PHP_SELF"];?>">
<div align="center">
<table width="70%">
<tr>
<td><b>Patch Description</b></td>
<td width="40%"><textarea name="file_desc" value="<?=$row[0]?>" cols='50' rows='8' ></textarea><br><br></td>
</tr>
<tr><td colspan=2><input type='submit' value='edit'></div></td></tr>
</table>
</div>
</form>
<?}?>
<br><br><p><a href='pedit.php'>Go back to patch edit page</a></p>
<?php
@ $db = mysql_pconnect("localhost", "root", "dbstuff3r");
if(!$db)
{
echo "error could not connect to the database. please try again later";
exit;
}
mysql_select_db("extranet");
$sql = "select file_desc from files where id='$id'";
$result = mysql_query($sql);
if(!$result)
{
echo"Cannot execute query";
}
?>
<html>
<head>
<title>Update Patch Description</title>
</head>
<body>
<?
while($row = mysql_fetch_row($result)) {
echo $row[0];
//the data shows up when I echo it here but does not show up in the textarea
?>
<form name='dupdate' method='post' action="<?php echo $_SERVER["PHP_SELF"];?>">
<div align="center">
<table width="70%">
<tr>
<td><b>Patch Description</b></td>
<td width="40%"><textarea name="file_desc" value="<?=$row[0]?>" cols='50' rows='8' ></textarea><br><br></td>
</tr>
<tr><td colspan=2><input type='submit' value='edit'></div></td></tr>
</table>
</div>
</form>
<?}?>
<br><br><p><a href='pedit.php'>Go back to patch edit page</a></p>