
21/01/2008, 05:10
|
| | Fecha de Ingreso: enero-2008
Mensajes: 58
Antigüedad: 17 años, 2 meses Puntos: 1 | |
Ayuda al Editar nombre de foto tengo este codigo:
Código:
<?
$servidor = "localhost";
$usuario = "";
$contrasenia = "";
$cnx = mysql_connect($servidor,$usuario,$contrasenia) or die(mysql_error());
mysql_select_db("guiamusica_bd",$cnx) or die (mysql_error());
?>
<!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>Documento sin título</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
color: #000000;
}
.letra {
font-family: HandelGotDLig;
font-size: 12px;
color: #000000;
margin-left: 350px;
}
.cwe1 {
font-family: HandelGotDLig;
font-size: 12px;
color: #FFFFFF;
background-image: url(../imagenes/fondo%20botones.jpg);
background-repeat: no-repeat;
background-position: center center;
font-weight: bold;
width: 80px;
}
.cwe {
font-family: HandelGotDLig;
font-size: 12px;
color: #000000;
background-color: #FFFFFF;
border: 1px outset #000000;
vertical-align: middle;
}
.transparente {
background-color: transparent;
font-family: HandelGotDLig;
font-size: 12px;
color: #000000;
width: 580px;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
}
-->
</style>
</head>
<body>
<form method="post" name="form3" id="form3" enctype="multipart/form-data" target="frame1">
<table width="800" border="0">
<tr class="cwe">
<td><div align="center">
<input name="foto" type="file" class="cwe" id="fichero" />
<input name="Submit" type="submit" class="cwe1" value="Añadir foto" />
</div></td>
<?
if(isset($_POST["Submit"]))
{
$imagen = $_FILES["foto"]["name"];
$imagenTmp = $_FILES["foto"]["tmp_name"];
if(copy($imagenTmp,"fotos/".$_GET["grupo"]."/".$imagen))
{
echo "<br />Archivo subido";
}
else
{
echo "<br />Error";
}
$foto = $_FILES["foto"]["name"];
$grupo = $_GET["grupo"];
$c = "INSERT INTO fotos (id_foto,foto,grupo) VALUES ('','$foto','$grupo')";
$q = mysql_query($c) or die (mysql_error());
?>
<script>
window.open('marco edicion artistas fotos artista.php?grupo=<? echo $_GET["grupo"]; ?>','frame1');
</script>
<?
}
?>
</tr>
</table>
<table width="800" border="0">
<?
$grupo = $_GET["grupo"];
$consulta = "SELECT * FROM fotos WHERE grupo='$grupo'";
$query = mysql_query($consulta) or die (mysql_error());
$filas = mysql_num_rows($query);
if($filas>0)
{
while($res = mysql_fetch_array($query))
{
?>
<tr class="cwe">
<td width="32" height="34" class="cwe"><a href="fotos/<? echo $_GET["grupo"]; ?>/<? echo $res["foto"]; ?>"><img src="fotos/<? echo $_GET["grupo"]; ?>/<? echo $res["foto"]; ?>" width='30' height='30' border="0"/></a></td>
<td width="503" class="cwe"><div align="center">
<input name="nombre" type="text" class="transparente" value="<? echo $res["foto"]; ?>"/>
</div></td>
<td width="82" class="cwe"><span class="cwe">
<input name="editar" type="submit" class="cwe1" value="Editar"/>
</span></td>
<td width="83" class="cwe">
<input name="eliminar" type="submit" class="cwe1" value="Eliminar"/>
</td>
</tr>
<?
}
}
else
{
echo "<div class='letra'>no hay fotos</div>";
}
?>
<?
if(isset($_POST["editar"]))
{
$fotos = $_POST["nombre"];
$fotoss = $res["foto"];
$consulta = "UPDATE fotos SET foto='$fotos' WHERE foto='$fotoss'";
$query = mysql_query($consulta) or die (mysql_error());
echo $consulta;
}
?>
</table>
</form>
</body>
</html>
<?
mysql_close($cnx);
?>
el casi esque al darle al boton no funciona el codigo de editar, me envia la varible $fotoss vacia y la variable $fotos es igual al ultimo registro que he insertado... |