Y para poder editar y borrar comentarios editaremos
comentarios.php borrarcomentario.php editarcomentario.php comentarios.php Código PHP:
<?php
require ('../includes/connect.php');
require ('menu.php');
$result=mysql_query("SELECT * FROM comentarios",$connect);
$totalregistros=mysql_num_rows($result);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0){
echo "<script type=\"text/javascript\">window.open('no_content.php', '_self');</script>";
exit;
}
while($row=mysql_fetch_array($result))
{
?>
<html>
<head>
<title>Panel de Administracion :::.</title>
<link rel=stylesheet href="estilo.css" type="text/css">
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="90%" valign="top" class="td"><div align="left"><span class="Texto"><?=$row[comentario];?></span></div>
</td>
<td width="5%" valign="top" class="td"><? echo '<a href="editarcomentario.php?id='.$row[id_comentario].'">Editar</a>';?></td>
<td width="5%" valign="top" class="td"><? echo '<a href="borrarcomentario.php?id='.$row[id_comentario].'">Borrar</a>';?></td>
</tr>
</table>
<p> </p>
</body>
</html>
<?
}
mysql_free_result($result)
?>
borrarcomentario.php Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Borrar registro</title>
</head>
<body>
<?php
require ('../includes/connect.php');
// $connect = Conectarse();
$id =$_GET['id'];
$sql = "DELETE FROM comentarios WHERE id_comentario ='$id'";
$result = mysql_query($sql, $connect) or die("Error en consulta $sql:".mysql_error() );
//echo "Anuncio borrado";
header("Location: panel.php");
?>
</body>
</html>
editarcomentario.php Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sistema de Noticias de KarlicOs -Edita Noticia :::.</title>
<link rel="stylesheet" href="estilo.css" type="text/css" />
</head>
<body>
<?php include('menu.php');?>
<div style="width:700px;margin:50px auto" align="left" class="Texto">
<?php
include ('../includes/connect.php');
$id = $_GET["id"];
//$nick=$_GET["nick"];
$result=mysql_query("SELECT * FROM comentarios WHERE id_comentario= '$id'",$connect);
while($row=mysql_fetch_array($result))
{
?>
<form action="edit.php" method="post">
<input name="nick" id="nick" value = "<?php echo $row[nick];?>"><br>
eMail:<br>
<input name="email" type="text" id="email" value= "<?php echo $row[email]; ?>" size="70"><br><br>
Comentario:<br>
<textarea name="noticia" cols="70" rows="10"><?php echo $row[comentario]; ?></textarea>
<script type="text/javascript" src="editor/nicEdit.js"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>
<br>
<input type="submit" value="Editar" class="button"><br>
</form>
<?php
}
mysql_free_result($result);
//mysql_close($connect);
?>
</div>
</body>
</html>
Ahora me voy!! Un saludo!!