Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/07/2005, 14:14
Avatar de rigtersir
rigtersir
 
Fecha de Ingreso: enero-2004
Ubicación: Mexico City
Mensajes: 28
Antigüedad: 20 años, 3 meses
Puntos: 0
Exclamación Edicion de noticias

Estoy desarrollando un sistema de noticias, iva bien hasta que intente hacer un formulario con el cual pudiera editar una noticia
Al principio parecia que todo andaba bien pero al agregar una segunda noticia y editarla supuestamente lo hacia....pero aqui el problema, tambien modificaba las noticias que estaban antes, es decir la edicion se hacia pero modificaba los datos de otras noticias con datos identicos, toda la tabla de noticias era igual

Cuando comence logre mostrar los titulos de las noticias dentro de un select y que al seleccionar alguna opcion me apareciera esta dentro de un formulario. Aqui el codigo:

edit.php
Código PHP:
<?
include ("config.php");
mysql_connect("$host","$usuario","$password");

echo 
'<FORM METHOD="POST" ACTION="edit.php?accion=show"><b>Editar Noticia</b><br><br>';

$sSQL="Select title From news Order By id";
$result=mysql_db_query("$nombredb",$sSQL);

echo 
'<select name="title">';

while (
$row=mysql_fetch_array($result))
{echo 
'<option>'.$row["title"];}
mysql_free_result($result)

?>

</select>
<INPUT TYPE="SUBMIT" value="Editar">
</FORM>
</center>
<?

if($accion=="show"){

$title$_POST['title'];
$query mysql_query("SELECT * FROM rps_news where title='$title'");

while(
$row mysql_fetch_array($query)){

echo 
"<center><b>Editar Noticia</b></center><br>
<center><form method=post action=edit2.php?action=editn>
<table border=0 width=10% cellpadding=0 height=21>
<tr>
<td width=153% height=1 align=right>Autor:</td>
<td width=74% height=1>&nbsp;<input type=text name=autor size=25 value=$row[autor]></td>
</tr>
<tr>
<td width=153% height=21 align=right>E-mail:</td>
<td width=74% height=21>&nbsp;<input type=text name=email size=25 value=$row[email]></td>
</tr>
<tr>
<td width=153% height=21 align=right>Fecha:</td>
<td width=74% height=21>&nbsp;<input type=text name=fecha size=25 value=$row[fecha]></td>
</tr>
<tr>
<td width=153% height=21 align=right>Imagen:</td>
<td width=74% height=21>&nbsp;<input type=text name=imagen size=25 value=$row[imagen]></td>
</tr>
<tr>
<td width=153% height=16 align=right>
Titulo:</td>
<td width=74% height=16>&nbsp;<textarea name=title rows=1 cols=25>$row[title]</textarea></td>
</tr>
<tr>
<td width=153% height=21 align=right>
Texto:</td>
<td width=74% height=21>&nbsp;<textarea rows=8 name=noticia cols=56>$row[noticia]</textarea></td>
</tr>
<tr>
<td width=153% height=21 align=right></td>
<td width=74% height=21>
<p align=center><input type=submit value=Editar name=editar>
</td>
</tr>
</table>
</form></center>"
;
}
}
?>
edit2.php
Código PHP:
<?php
include("config.php");

if(
$action=="editn"){

$sql "UPDATE rps_news set autor='$autor',email='$email',fecha='$fecha',imagen='$imagen',title='$title',noticia='$noticia'";

$resp mysql_query($sql);

echo 
"<center><font color=#990000 face=Tahoma size=1><b>Noticia Editada</b></font><br>
<a href=edit.php>Volver</a></center>"
;

}

?>
Ojala alguien me pueda ayudar a resolver este problemam se los agradeceria mucho
__________________
° Rigter °
Portfolio & Blog
http://www.rigtersir.com