Dejo el codigo por si alguien me ayuda.
Código:
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="estilo.css"> <script type="text/javascript"> function showimage() { if (!document.images) return document.images.imagen.src= 'imagenes/' + document.formulario.imagen.options[document.formulario.imagen.selectedIndex].value }</script> </head> <body bgcolor="#FFFFFF"> <? include ("top.php"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="20%" valign="top"><? include ("inicio.php"); ?> </td> <td width="80%" valign="top"><? // Listado de noticias // Armo una conexion al servidor mysql $coneccion = mysql_connect($host_db, $user_db, $pass_db); mysql_select_db($base_db, $coneccion); if ($REQUEST_METHOD<>"POST") { // Busco todos las categorias o tipos de noticias disponibles $sql_tipos = "select * from tipo_noticias order by desc_tipo_noticia "; $result_tipos = mysql_query($sql_tipos, $coneccion); // Busco los datos del registro que voy a editar $sql = "select * from noticias where id_noticia = $id_noticia"; $result = mysql_query($sql, $coneccion); $myrow=mysql_fetch_array($result); ?> <script language="JavaScript" src="richedit.js"></script> <? $richEdit0 = $myrow[text2]; ?> <form method="POST" action="<?php echo $PHP_SELF ?>" name="formulario"> <table border="0" width="100%"> <tr> <td width="100%" colspan="2" bgcolor="#DBDBDB" height="20"><b>Editar Noticias</b></td> </tr> <tr> <td width="30%" height="20"> <p aling="right">Categoría: </td> <td width="70%" height="20"> <select size="1" name="cod_tipo_noticia"> <? // Muestro todos las categorias o tipos de noticias para armar la lista desplegable while($myrow_tipos = mysql_fetch_array($result_tipos)) { if ($myrow_tipos[id_tipo_noticia] == $myrow[cod_tipo_noticia]) { echo "<option value=$myrow_tipos[id_tipo_noticia] selected>$myrow_tipos[desc_tipo_noticia]</option>"; } else { echo "<option value=$myrow_tipos[id_tipo_noticia]>$myrow_tipos[desc_tipo_noticia]</option>"; } } ?> </select> </td> </tr> <tr> <td width="30%" height="20"> <p aling="right">Subtítulo superior: </td> <td width="70%" height="20"> <input type="text" name="subtitulo" size="32" value="<? echo $myrow[subtitulo]; ?>" maxlength="100"> </td> </tr> <tr> <td width="30%" height="20"> <p aling="right"> Titulo: </td> <td width="70%" height="20"> <input type="text" name="titulo" size="32" value="<? echo $myrow[titulo]; ?>" maxlength="50"> </td> </tr> <tr> <td width="30%"> <p aling="right">Texto: </td> <td width="70%"> <textarea rows="3" name="text1" cols="27"><? echo $myrow[text1]; ?></textarea> </td> </tr> <tr> <td width="30%"> <p aling="right">Texto extendido: </td> <td width="70%"> <script language="JavaScript"> <!-- var editor = new EDITOR(); <? $richEdit0 = addslashes(preg_replace("/\r|\n/", '', $richEdit0)); ?> editor.create("<? echo $richEdit0; ?>"); //--> </script> </td> </tr> <tr> <td width="30%" height="20"> <p aling="right">Imagen: </td> <td width="70%" height="20"> <? $imagen = $myrow['imagen']; $directorio = 'imagenes' ; //aqui se coloca el directorio q queremos listar $dir = opendir("$directorio") ; //aqui se abre el directorio echo "<select name=imagen onChange= showimage()> "; echo "<option value=sin_imagen.png>Sin imagen</option>"; echo "<option selected>$imagen</option>"; while ($file = readdir($dir)) { //aqui es donde leemos el directorio if ($file != "." && $file != "..") { //esto es para que no nos muestre la salida a "atras" echo "<option value=$file>$file</option>"; } } echo" </select>"; closedir($dir); //aqui cerramos la carpeta echo"<br><img src=imagenes/$imagen name=imagen onError=this.onerror='null';this.src='blanco.gif'>"; //aqui se mostraran nuestras imagenes seleccionadas ?></td> </tr> <tr> <td width="30%" height="27"></td> <td width="70%" height="27"> <input type="submit" value="Editar" name="envio"> <input type="hidden" name="id_noticia" value="<? echo $myrow[id_noticia]; ?>"> </td> </tr> </table> </form> <p> </p> <? } else { // Actualizamos el registro con los nuevos valores // Armo el update $sql = "update noticias set cod_tipo_noticia = '$cod_tipo_noticia', titulo = '$titulo', subtitulo = '$subtitulo', text1 = '$text1', text2 = '$richEdit0', imagen = '$imagen' where id_noticia = $id_noticia "; $result = mysql_query($sql, $coneccion); if (!mysql_error()) { echo "La noticia $nombre ha sido actualizada exitosamente<br>"; } else { echo "ERROR al actualizar la noticia - ". mysql_errno().":". mysql_error()."<br>"; } } ?></td> </tr> </table> </body> </html>