Jump to content

help need to get the selected item into a textarea in php


bindiya

Recommended Posts

I have a php form which shows all comments of the webpage  stored in  the database.

When i click on the edit button the corresponding 'comments' datas should appear in the textarea.

 

how can i do this,

pasting my piece of code

 

 

                                        $query="select *from comments order by id desc";

 

$result=mysql_query($query);

echo "<table width='700' align='center' border=1><tr bgcolor='green' align='center'><td><font color='black'> SlNo </font></td><td><font color='black'>Comment</font></td><td><font color='black'>  Date Posted  </font></td><td>Edit/Delete</td></tr></b>";

while($row = mysql_fetch_row($result))

{

$d=$row['0'];

$id=$row['0'];

$name=$row['1'];

$date_uploaded=$row['2'];

 

echo "<td>$id</td><td>$name</td>".

"<td>$date_uploaded</td>".

"<td><a href='edit_comments.php?id=$id'>Edit </a></td>".

"</tr>";

}

 

echo "</table>";

 

}

if(isset($_GET['id']))

{

 

$id    = $_GET['id'];

mysql_connect('localhost','root','') or die("Cannot connect to the Host");

mysql_select_db('sample') or die("Cannot connect to the Database !!");

$query = "SELECT comments FROM comments_tble WHERE id = '$id' ";

 

$result = mysql_query($query);

$row=mysql_fetch_row($result);

echo"<input type='text' col id='edit_comments' value='$row[0]' width='250' height='10' >";

 

 

 

exit;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.