Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/05/2010, 13:25
jairopicco
 
Fecha de Ingreso: mayo-2010
Mensajes: 32
Antigüedad: 13 años, 11 meses
Puntos: 0
Modificar imagen de la base de datos y de su directorio

Este es el administrador

<table width="400" align="center">

<tr class="encabezado">
<td valign="top" align="center" width="400">
Titulo</td>
<td valign="top" align="center" width="100">
Texto</td>
<td valign="top" align="center" width="100">
Imagen</td>
<td valign="top" align="center" width="25">&nbsp;</td>
<td valign="top" align="center" width="25">&nbsp;</td>
</tr>

<?php
$sql="select * from noticias";
$res=mysql_query($sql,$con);
while ($reg=mysql_fetch_array($res))
{
?>

<tr class="registros">
<td valign="top" align="center" width="400">
<?php
echo chao_tilde($reg["titulo"]);
?>
</td>
<td valign="top" align="center" width="100">
<?php
echo $reg["texto"];
?>
</td>
<td valign="top" align="center" width="100">
<?php
echo $reg["imagen"];
?>
</td>
<td valign="top" align="center" width="25">
<a href="noticias/modificar.php?id=<?php echo $reg["id"];?>" title="Modificar"><img src="noticias/ima/editar.png" border="0"></a></td>
<td valign="top" align="center" width="25">
<a href="javascript:void(0)" title="Eliminar" onClick="eliminar('<?php echo $reg["id"];?>')"><img src="noticias/ima/eliminar.png" border="0"></a></td>
</tr>
<?php
}
?>
<tr>
<td valign="top" align="right" width="400" colspan="5">
<a href="noticias/agregar.php" title="Agregar Empelados"><img src="noticias/ima/add48x48.png" width="24" height="24" border="0"></a></td>
</tr>
</table>


Este es el archivo modificar.php

<?php
require_once("conexion.php");
$sql="select * from noticias where id=".$_GET["id"]."";
$res=mysql_query($sql,$con);
?>

<html>
<head>
<title>Modificar Noticia</title>
<script language="javascript" type="text/javascript" src="js/funciones.js"></script>
</head>

<body onLoad="limpiar()">
<?php
if ($reg=mysql_fetch_array($res))
{
?>

<form action="edit.php" method="post" enctype="multipart/form-data" name="form">
<table align="center" width="400">
<tr>
<td valign="top" align="center" width="400" colspan="2">
<h3>Modificar Noticia</h3>
</td>
</tr>

<tr>
<td align="right" valign="top" width="200">
Titulo
</td>
<td valign="top" align="left" width="200">
<input type="text" name="titulo" value="<?php echo $reg["titulo"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200">
Texto
</td>
<td valign="top" align="left" width="200">
<input type="text" name="texto" value="<?php echo $reg["texto"];?>" />
</td>
</tr>

<tr>
<td align="right" valign="top" width="200">
Imagen
</td>
<td valign="top" align="left" width="200"><label>
<input name="imagen" type="file" id="imagen" value="<?php echo $reg["imagen"];?>">
</label></td>
</tr>

<tr>
<td valign="top" align="center" width="400" colspan="2">
<input type="hidden" name="id" value="<?php echo $_GET["id"];?>">
<input type="button" value="Volver" title="Volver" onClick="history.back();" />
&nbsp;&nbsp;||&nbsp;&nbsp;
<input name="Enviar" type="submit" title="Modificar" value="Modificar" />
</td>
</tr>

</table>
</form>
<?php
}
?>

</body>
</html>


Este es el archivo edit.php

Aca se me enredo todo

<?php
//print_r($_POST);
require_once("conexion.php");

$sql="update noticias
set
titulo='".$_POST["titulo"]."',
texto='".$_POST["texto"]."',
where
id=".$_POST["id"]."";
//echo $sql;
$res=mysql_query($sql,$con);
echo "<script type=''>
alert('Los datos del empleado fueron modificados correctamente');
window.location='index.php';
</script>
";
//if (isset($_FILES['archivo']['name']) && !empty($_FILES['archivo']['name']))
?>


Tambien tengo problemas al eliminar, pero eso lo vemos despues.

Última edición por jairopicco; 14/05/2010 a las 13:26 Razón: Opciones Adicionales