
22/12/2011, 15:43
|
| | Fecha de Ingreso: diciembre-2011
Mensajes: 8
Antigüedad: 13 años, 2 meses Puntos: 0 | |
Respuesta: Problema al visualizar imagen php mysql Vale aki te adjunto todo el codigo
Las dos tablas son:
Create table usuario(
usuario varchar(20),
Primary key (usuario)
) ENGINE=INNODB;
create table fotos(
usuario varchar(20),
foto1 varchar(50),
foto2 varchar(50),
Primary Key (usuario)
) ENGINE=INNODB;
El Formulario HTML es:
<html>
<head>
</head>
<body>
<form method="POST" action="5.php">
usuario
<input type="text" name="usuario">
url1
<input type="text" name="url1">
url2
<input type="submit">
</body>
</html>
Y el codigo PHP:
<?php
$conexion=mysql_connect("localhost","root","root") ;
if(isset($_POST['usuario'])){
$variable = $_POST['usuario'];
}
mysql_select_db("web",$conexion);
$sql = sprintf("SELECT url1, url2 FROM usuario,fotos
WHERE '%s' = usuario.usuario AND usuario.usuario=fotos.usuario",mysql_real_escape_s tring($variable));
$res=mysql_query($sql, $conexion);
$row_res = mysql_fetch_assoc($res);
?>
<body>
<?php
do { ?>
<img src="<?php echo $row_res['url'];?>" />
<?php
}
while ($row_res = mysql_fetch_assoc($res));
?>
</body> |