Ver Mensaje Individual
  #4 (permalink)  
Antiguo 18/10/2009, 11:52
xfer2
(Desactivado)
 
Fecha de Ingreso: junio-2009
Mensajes: 256
Antigüedad: 14 años, 10 meses
Puntos: 1
Respuesta: [aporte] subir y redimencionar imagen parte I

Parte IV.

archivo donde se mostrara las imagenes agregadas.

index.php

Código PHP:

<?php 
    
include("includes/conexion.php");
?>
<!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>
<script language="javascript" type="text/javascript">
    function borrar(cod){
        con = confirm("Desea borrar la imagen");
            if(con==true){
                document.frmindex.action = "eliminar.php?cod="+cod;
                document.frmindex.submit();
            }
    }
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lista imagenes</title>
</head>
<body>
<a href="agregarimagen.php">Agregar imagen</a>
<br/><br/>
<form name="frmindex" method="post">
<table border = "0" cellpadding="0" cellspacing = "0">
    <?php                
        $sql_categorias 
"SELECT * FROM imagenes";
        
$rpta_categorias mysql_query($sql_categorias) or die(mysql_error());
        
//$result = "SELECT * FROM ks_obras";
                    
        //$query = mysql_query($result) or die(mysql_error());
        
$columnes 3# Número de columnas (variable)
            
                
for ($i=1$row mysql_fetch_array($rpta_categorias); $i++) {
                    
$resto = ($i &#37; $columnes); # Número de celda del <tr> en que nos encontramos 
                        
if ($resto == 1) {
                        
    
?>
    <tr>
      <?php        
                        
# Si es la primera celda, abrimos <tr> 
      
?>
      <td width="175">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="2">&nbsp;</td>
          </tr>
          <tr>
            <td width="155" bgcolor="#AFAFAF">
               <?php echo "Foto N° $i"?>            </td>
            <td width="11">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2"><?=$row['nombres'].' '.$row['apellidos'];?></td>
          </tr>
          <?php
                
if($row['imagen_thb']==""){ 
                    echo 
"<tr>";
                    echo 
"<td><img src=\"images/user.jpg\" /></td>";
                    echo 
"</tr>";
                }else{
              
          
?>
          <tr>
            <td colspan="2">
                  <img src = "thumbnail/<?=$row['imagen_thb']; ?>" border="0" />            
            </td>
          </tr>
          <?php
                  
}
          
?>
          <tr>
            <td colspan="2">              
                <a href="editarimagen.php?imagen=<?=$row['idimagen']; ?>">Editar</a> | 
                    <a href="javascript:void(0);" onclick="borrar('<?=$row['idimagen']; ?>');">Borrar</a>            </td>
          </tr>
        </table>          </td>
      <?php        if ($resto == 0) {    ?>
    </tr>
    <?php            # Si es la última celda, cerramos </tr> 
                

                                
                    if (
$resto <> 0) { # Si el resultado no es múltiple de $columnes acabamos de rellenar los huecos 
                        
$ajust $columnes $resto# Número de huecos necesarios 
                            
for ($j 0$j $ajust$j++) {    
    
?>
    <tr>
      <td>&nbsp;</td>
      <?php                    }             ?>
    </tr>
    <?php
                    
# Cerramos la última línea
                                            
    
?>
</table>
</form>
<?php
        mysql_close
($cn);
?>
</body>
</html>
archivo mostrar y editar imagen.

Código PHP:

<?php
    
include("includes/conexion.php");
    
    
$sql_imagen "SELECT * FROM imagenes where idimagen = '".$_GET['imagen']."'";
    
$rpta_imagen mysql_query($sql_imagen) or die(mysql_error());
    
$fila_imagen mysql_fetch_array($rpta_imagen);
    
?>
<!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=utf-8" />
<title>Editar imagen</title>
</head>

<body>
<form action="process.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <input type = "hidden" name = "editar" id = "editar" value = "1" />
    <input type = "hidden" name = "codigo" id = "codigo" value = "<?=$_GET['imagen']; ?>" />
    <input type="hidden" name="FotoHdd" id="FotoHdd" value="<?php echo $_GET['FotoHdd'];?>" >
    <input name="nombreFoto" type="hidden" value="<?php echo $fila_imagen['imagen'];?>" />
    <input name="nombreFotoThb" type="hidden" value="<?php echo $fila_imagen['imagen_thb'];?>" />
  <table width="500" border="0" cellspacing="1" cellpadding="3">
    <tr>
      <td width="84">Nombres</td>
      <td colspan="2"><input type="text" name="nombres" id="nombres" value = "<?=$fila_imagen['nombres']; ?>" /></td>
      <td width="138" rowspan="4" valign="top"><img src = "thumbnail/<?=$fila_imagen['imagen_thb']; ?>" border="0" /></td>
    </tr>
    <tr>
      <td>Apellidos</td>
      <td colspan="2"><input type="text" name="apellidos" id="apellidos" value = "<?=$fila_imagen['apellidos']; ?>" /></td>
    </tr>
    <tr>
      <td>Subir imagen</td>
      <td colspan="2"><input type="file" name="imagen" id="imagen" /></td>
    </tr>
    
    <tr>
      <td>&nbsp;</td>
      <td width="110"><center><input type="submit" value="Editar" /></center></td>
      <td width="139"><center><input type="button" value="Cancelar" onclick="javascript:document.location.href='index.php';" /></center></td>
    </tr>
  </table>
</form>
</body>
</html>

eso es todo. si hay duda sobre la aplicacion, me lo dicen.

saludos.

Última edición por xfer2; 18/10/2009 a las 11:53 Razón: corecion del texto.