Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/08/2009, 17:41
hollowmanf
 
Fecha de Ingreso: enero-2009
Mensajes: 246
Antigüedad: 15 años, 3 meses
Puntos: 1
Visualizar Comentarios Aprobados

Hola amigos tengo un php que me da de alta mi noticia.

alta noticia:

Código PHP:
<?php
    
@session_start();
    require_once(
'auth.php');
    require_once(
'config.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>Mi Perfil</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {color: #0066CC}
.Estilo2 {color: #006699}
.Estilo11 {    color: #006699;
    font-size: 14px;
}
.style1 {color: #000000}
-->
</style>
</head>
<body>
<h1 class="Estilo1"><img src="logo.jpg" alt="UPCN" width="170" height="50" /><span class="Estilo11">Delegaci&oacute;n Nacional del Ministerio de Desarrollo Social de la Naci&oacute;n</span></h1>
<h1 class="Estilo2">Perfil de:  <?php echo $_SESSION['SESS_LAST_NAME'];?></h1>
<p><a href="member-profile.php">Mis Datos</a> | <a href="consultas.php">Consultas</a> | <a href="mensajes.php">Mensajes</a> | <a href="ayudas.php">Ayudas</a> | <a href="novedades-afiliados.php">Novedades Afiliados</a> | <a href="logout.php">Logout</a></p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<br>
<FORM METHOD="POST" ACTION="insert_noticia.php">

<table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="54%" id="AutoNumber1" height="119">
  <tr bgcolor="#CCCCCC">
    <td height="19" colspan="6"><span class="Estilo3 style1"><font face="Verdana" size="1">
    INGRESAR UN NUEVO MENSAJE:</font></span></td>
  </tr>
  <tr>
    <td height="19" colspan="6">&nbsp;</td>
  </tr>
  <tr>
    <td width="25%" height="24"><strong><font face="Verdana" size="1">Titulo </font></strong></td>
    <td width="1%" height="24">&nbsp;</td>
    <td width="28%" height="24"><INPUT NAME="titulo" MAXLENGTH="100" TYPE="TEXT" VALUE=""></td>
    <td width="6%" height="24"><strong><font face="Verdana" size="1">Autor:</font></strong></td>
    <td width="1%" height="24">&nbsp;</td>
    <td width="39%" height="24"><?php echo $_SESSION['SESS_LAST_NAME'];?></td>
  </tr>
  <tr>
    <td width="25%" height="19"><strong><font face="Verdana" size="1">Comentario:</font></strong></td>
    <td width="1%" height="19">&nbsp;</td>
    <td height="19" colspan="4">
        <label>
          <textarea name="comentario" cols="70" rows="15"></textarea>
        </label>          </td>
  </tr>
  <tr>
    <td height="19" colspan="6">&nbsp;</td>
  </tr>
  <tr>
    <td height="19" colspan="6"><div align="center">
          <input name="Reset" type="RESET" Value="Limpiar Datos">&nbsp;&nbsp;
          <INPUT NAME="boton" TYPE="SUBMIT" VALUE="Grabar Datos">
    </div></td>
  </tr>
</table>
</form>
</body>
</html>
Tengo mi otro php que recoge los datos y los graba en la db.

Código PHP:
<?php
$con 
mysql_connect("localhost","USUARIO","PASS");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("BASE DE DATOS"$con);

$sql="INSERT INTO noticia (titulo,autor,comentario,estado) 
VALUES 
('$_POST[titulo]','$_POST[autor]','$_POST[comentario]','$_POST[estado]')"
;


if (!
mysql_query($sql,$con))
  {
  die(
'Error: ' mysql_error());
  }
//echo "1 record added";

mysql_close($con);
header ("Location: member-index.php");
?>
Ahora por otro lado tengo mi php que aprueba las noticias antes de mostrarlas:

Código PHP:
<script> 
  
function confir(msj,url){ 
  
if(confirm(msj)){ 
window.location = url; 

  
  

  
</script> 
<body>  
  
<form id="form1" name="form1" method="post" action="">  
  <p>  
    <?PHP  
require_once('config.php'); 
$link mysql_connect(DB_HOSTDB_USERDB_PASSWORD); 
$db mysql_select_db(DB_DATABASE);
 
$resultmysql_query("select * from noticia where Aprobado<1") or die('Error: '.mysql_error());    
  
?>  
    <span class="style13">Listado de Noticias <b><u>Por Aprobar</u></b></span></p>  
  <p>&nbsp;  </p>
  <div><center><?php if(!mysql_num_rows($result)) echo "<b>No se encontraron Noticias por Aprobar</b>"?></center></div> 
  <table width="800" border="0" align="center" cellpadding="2" cellspacing="0" >  
  <tr bgcolor="#6699CC">  
    <td><div align="center" class="style14"><span class="style15 style3 style4">ID</span></div></td>  
    <td><div align="center" class="style14"><span class="style15 style3 style4">TITULO</span></div></td>  
    <td><div align="center" class="style14"><span class="style15 style3 style4">NOTICIA</span></div></td>  
    <td><div align="center" class="style14"></div></td>  
    <td><div align="center" class="style14"></div></td>  
    <td><div align="center" class="style14"></div></td>  
    <td><div align="center"><span class="style6"><span class="style14"></span></span></div></td>  
    <td><div align="center"><span class="style6"><span class="style14"></span></span></div></td>  
    <td><div align="center"><span class="style6"><span class="style14"></span></span></div></td>  
  </tr>  
    
    <?php   
      
     
while ($row mysql_fetch_array($result)){  
    echo
"<tr>";  
    echo
"<td><div align='center'><span class='style3'>" .$row['id_comentario']. "</span></div></td>" ;  
    echo
"<td><div align='center'><span class='style3'>" .$row['titulo']. "</span></div></td>" ;  
    echo
"<td><div align='center'><span class='style3'>" .$row['comentario']. "</td>" ;  
    echo
"<td ><div align='center'><span class='style2'> 
   <a href=\"Javascript:confir('Realmente deseas eliminar esta noticia','eliminar_noticia.php?id={$row['id_comentario']}')\">ELIMINAR</a></span></div></td>"
;  
    echo
"<td ><div align='center'><span class='style2'> 
    
    <a href='modifica_noticia.php?id=" 
.$row['id_pf']. "'>VER</a></span></div></td>";  
    echo
"<td ><div align='center'><span class='style2'> 
    <a href=\"Javascript:confir('Realmente deseas Aprobar esta noticia','aprobar_noticia.php?id={$row['id_comentario']}')\">APROBAR</a></span></div></td>"
;  
    echo
" </tr>";  
    }  
    
?>  
</table>   
  
<p class="style5">| <a href="index.php">Inicio</a> |</p>  
</form> 
 
</body> 
</html>
Y por ultimo tengo mi listador de noticias:

Código PHP:
<?php
    
@session_start();
    require_once(
'auth.php');
    require_once(
'config.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>Mi Perfil</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {color: #0066CC}
.Estilo2 {color: #006699}
.Estilo11 {    color: #006699;
    font-size: 14px;
}
.style1 {color: #000000}
-->
</style>
</head>
<body>
<h1 class="Estilo1"><img src="logo.jpg" alt="UPCN" width="170" height="50" /><span class="Estilo11">Delegaci&oacute;n Nacional del Ministerio de Desarrollo Social de la Naci&oacute;n</span></h1>
<h1 class="Estilo2">Perfil de:  <?php echo $_SESSION['SESS_LAST_NAME'];?></h1>
<p><a href="member-profile.php">Mis Datos</a> | <a href="consultas.php">Consultas</a> | <a href="mensajes.php">Mensajes</a> | <a href="ayudas.php">Ayudas</a> | <a href="novedades-afiliados.php">Novedades Afiliados</a> | <a href="logout.php">Logout</a></p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<br>
<FORM METHOD="POST" ACTION="insert_noticia.php">
 <?PHP
require_once('config.php');
$link mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
$db mysql_select_db(DB_DATABASE);
$resultmysql_query("select * from noticia") or die('Error: '.mysql_error());  

?>
<table width="897" border="0" align="center" cellpadding="2" cellspacing="0">  
  <tr bgcolor="#6699CC">  
    <td bgcolor="#CCCCCC"><div align="center" class="style14">
      <div align="left"><span class="style1">VISUALIZAR NOTICIAS Y COMENTARIOS:</span></div>
    </div></td>
  </tr>  
    
    <?php   
      
     
while ($row mysql_fetch_array($result)){  
    echo
"<tr>";  
    echo
"<td><div align='center'><span class='style3'>" .$row['titulo']. "</span></div></td>" ;  
    echo
"<td><div align='center'><span class='style3'>" .$row['comentario']. "</td>" ;  
    echo
"<td ><div align='center'><span class='style2'> 
   </tr>"
;  
    }  
    
?>  
</table>  
<p>&nbsp;</p>
</form>
</body>
</html>

El problema que estoy teniendo es que me esta listando todas las noticias que dejan grabadas y solo necesito listar aquellas noticias que estan solo aprobadas por el administrador. Alguien podria ayudarme mirando el ultimo codigo a ver en donde estoy fallando.

Saludos y gracias