Jump to content

php code help need to hide a textarea after clicking a button


bindiya

Recommended Posts

I have a php form in which ,on click of a edit button the contents of that table row will be displayed in a text area (which appears on the click of that edit button).Below the textarear i have a submit and delete button,i can perform any action.Ater performing the save or delete click the text area should be hidden.

this is not happening,tried with js also.

 

 

pasting the code below

 

<form name='add_title' method='post' action=''><?php
	echo "<br><br>";

if(isset($_POST['update'])) 
{
if(isset($_GET['id'])) {
$id    = $_GET['id'];
$comments=$_POST['comment'];
$query1 = "update  comments set  comments='$comments' WHERE id = '$id' ";

$result = mysql_query($query1);
//$row=mysql_fetch_row($result);

}	
}	
if(isset($_POST['delete'])) 
{
if(isset($_GET['id'])) {
$id    = $_GET['id'];
$comments=$_POST['comment'];
$query1 = "delete from  comments  WHERE id = '$id' ";

$result = mysql_query($query1);


}	
}	
	$query="select count(*) from comments";
	$result =mysql_query($query);
	$row=mysql_fetch_row($result);
	$count= $row[0];		
	if($count!=0)

	{
		$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['3'];
			  
			echo	 "<td>$id</td><td>$name</td>".
				 "<td>$date_uploaded</td>".
				 "<td><a href='edit_comments.php?id=$id'>Edit </a></td>".
				 "</tr>";
		}
		if(isset($_GET['id'])) 
{

$id    = $_GET['id'];

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

$result = mysql_query($query);
$row=mysql_fetch_row($result);

echo"<center><table width='700' border='1'><tr><td >
<textarea name='comment' cols='80' rows='10'>$row[0]</textarea>
<td></tr><tr><td><a href='edit_comments.php?id=$id'><input type='submit' name='update' id='update' value='Save'></a><a href='edit_comments.php?id=$id'><input type='submit' name='delete' id='delete' value='Delete'></a>
</td><td></td></center>";


} 



		echo	"</table>";



}		else
	{
		echo "<table width='700' align='center'><tr bgcolor='white' align='center'><td><font color='red' size=2>No comments for  you.</font></td></tr></table>";
	}
	?>

 

Edit: Please use


tags when posting code.

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.