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;

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.