Foros del Web » Programando para Internet » PHP »

5 y cambio

Estas en el tema de 5 y cambio en el foro de PHP en Foros del Web. Hola a todos Yo muestro unas fotos tomadas de una bd mysql, pero entonces yo solo quiero que me muestre 5 fotos por fila, pero ...
  #1 (permalink)  
Antiguo 12/09/2007, 16:38
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
5 y cambio

Hola a todos

Yo muestro unas fotos tomadas de una bd mysql, pero entonces yo solo quiero

que me muestre 5 fotos por fila, pero el caso es que cuando yo voy insertando las

imagenes mediante un formulario, las fotos se van aumentando y la tabla alargandose......

Lo pueden ver acá

Entonces como hago para que solo muestre 5 fotos y haga un salto de linea ?¿

El codigo de donde muestro las fotos es:

fotos.php

Código PHP:
                  </table></td>
                <td width="12" height="12"></td>
                <td width="571"></td>
              </tr>
              <tr> 
                <td height="1730"></td>
                <td align="left" valign="top" style="padding:12px;"><table width="536" height="1706" border="0" cellpadding="0" cellspacing="0">
                    <!--DWLayoutTable-->
                    <tr> 
                      <td height="108" colspan="3" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <!--DWLayoutTable-->
                          <tr> 
                            <td width="520" height="14"></td>
                          </tr>
                          <tr>
                            <td height="46" valign="top"><div align="center"> 
                                                          
                                                                                           <? 
$codigo 
$_GET['codigo'];
echo 
"<h1>Código: $codigo </h1>";
@
mysql_connect('localhost','bd','pass') or die('No se puede conectar con el servidor mysql'); 
mysql_select_db("bd"); 
$codigo $_GET['codigo']; 
@
mysql_select_db('fotos') or die('No se puede seleccionar la base de datos especificada');  
$resultado = @mysql_query("SELECT imagen,tipo,id FROM subir_imagenes WHERE nombre = '$codigo'"); 

?>
                           <table width='588' height='510' border='0' cellpadding='0' cellspacing='0'>
                           <tr> 
<td height='19' colspan='2' align='left' valign='top'> 
                          <table width='100%' border='0' cellspacing='0' cellpadding='0'>
 <tr> 
                              <td width='523' height='19' valign='top'> <div align='right'><a href='javascript:history.back()'>&lt;-- 
                                              Atrás</a></div></td>
                            </tr>
                          </table></td>
                        <td width='36'></td>
                      </tr>
                      <tr> 
                        <td width='16' height='281'>&nbsp;</td>
                        <td width='536' valign='top'><table width='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='#FFFFD2'>
                            <!--DWLayoutTable-->
                            <tr> 
                              <td width='10' height='36'>&nbsp;</td>
                              <td colspan='9' valign='top' bgcolor='#FFFFD2'> 
                                <div align='center'> 
                                  <p><font size='2'><font size='2' face='Gill Sans MT'><font color='#000000' size='-1' face='Gill Sans MT'> 
                                    <br>
                                    RESIDENCIA EN ESQUINA EN PRIVADA VILLAS DEL 
                                    REY</font></font></font></p>
                                </div></td>
                            </tr>
                            <tr> 
                              <td height='14'></td>
                              <td width='2'></td>
                              <td width='112'></td>
                              <td width='15'></td>
                              <td width='112'></td>
                              <td width='10'></td>
                           <td width='112'></td>
                              <td width='16'></td>
                              <td width='112'></td>
                              <td width='35'></td>
                            </tr>
                             <tr> 
                                <?
//mostramos los registros
while ($row mysql_fetch_array($resultado)) {
$nombre $row["nombre"];
$id $row["id"];
echo 
"
 <td height='107'></td>
 <td colspan='1' valign='top'><a href='ver.php?id=$id'><img src='ver.php?id=$id' width='112' height='107' border='0'></a></td>
<td>&nbsp;</td>


"
;
}
?>
</tr>
                            <tr> 
                              <td height='17'></td>
                              <td></td>
                              <td></td>
                              <td></td>
                              <td></td>
                              <td></td>
                          <td></td>
                              <td></td>
                              <td></td>
                              <td></td>
                            </tr>
                            <tr> 
                              <td height='107'></td>
                              <td>&nbsp;</td>
                              <td valign='top'><!--DWLayoutEmptyCell-->&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td></td>
                              <td></td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                          </table>
Y el codigo de donde las tomo es:

ver.php

Código PHP:
<?php 
# Configurar las dos lineas siguientes 
@mysql_connect('localhost','bd','pass') or die('No se puede conectar con el servidor mysql');  

@
mysql_select_db('bd') or die('No se puede seleccionar la base de datos especificada');  
$datos = ($_GET['id']) ? 'id=' mysql_escape_string($_GET['id']) : "nombre='" mysql_escape_string($_GET['nombre']) . "'"
$resultado = @mysql_query("SELECT imagen,tipo FROM subir_imagenes WHERE " $datos); 

$imagen = @mysql_fetch_assoc($resultado) or die('Imagen inexistente'); 

header("Content-type: $imagen[tipo]"); 

print 
$imagen['imagen'];  
?>

SALUDOS
GRACIAS
__________________
*La amistad se multiplica cuando se divide*
  #2 (permalink)  
Antiguo 12/09/2007, 17:37
 
Fecha de Ingreso: agosto-2007
Mensajes: 66
Antigüedad: 16 años, 7 meses
Puntos: 1
Re: 5 y cambio

te recomiendo que revises este script;; es de una galeria de fotos como la tuya y tiene opcion de elegir fotos por fila, correr fotos automaticamente, etc

http://wingnut.freitagmorgen.de

saludos
  #3 (permalink)  
Antiguo 12/09/2007, 18:06
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Re: 5 y cambio

Vi el script y encontre esta parte:

$columns = 5;

$divheight = ceil(count($files)/$columns) * ($thumbwidth+6) + 6;
echo "<table height=$divheight width=100% cellspacing=0 cellpadding=0><tr valign=top><td>\n";
for ($y=0;$y<count($files);$y++)

Pero no se como podia dividirlo...
ceil... ?¿
Ayuda por favor

saludos
__________________
*La amistad se multiplica cuando se divide*

Última edición por reimonfranco; 12/09/2007 a las 18:13
  #4 (permalink)  
Antiguo 12/09/2007, 18:37
 
Fecha de Ingreso: septiembre-2007
Mensajes: 4
Antigüedad: 16 años, 7 meses
Puntos: 0
Re: 5 y cambio

Una opcion, ya qu estas revolviendo html con php en el codigo es poner un contador y cuando llegue a 5 agregues un <tr> en el codigo... explico...

Código PHP:
$iContador =0
while statement{

echo 
"<td...";

$iContador ++1;
  if 
$iContador {
  echo 
"</tr><tr>";
  
$iContador 0;
  }


  #5 (permalink)  
Antiguo 12/09/2007, 18:42
 
Fecha de Ingreso: agosto-2007
Mensajes: 66
Antigüedad: 16 años, 7 meses
Puntos: 1
Re: 5 y cambio

ceil -- Redondear fracciones hacia arriba

este script en la parte de arriba tiene las opciones para modificar su funcionamiento
Código PHP:
// --begin editable region

// Root directory
$root_dir ".";

// Thumbnail Columns  <<---- NUMERO DE IMAGENES A MOSTRAR POR LINEA
$columns 5;

// Maximal size of thumbnails in pixel   <<----TAMANO DE LA IMAGEN MINIATURA
$thumbwidth 100;

// Slideshow 0=no 1=yes  <<----- SI QUIERES QUE SE DESPLASEN LAS FOTOS AUTOMATICAMENTE
$slideshow 0;
        
// --end editable region 
  #6 (permalink)  
Antiguo 12/09/2007, 21:12
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Re: 5 y cambio

lo voy a checar
__________________
*La amistad se multiplica cuando se divide*
  #7 (permalink)  
Antiguo 13/09/2007, 12:27
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Re: 5 y cambio

vgarcias no entendi bien a que te refieres.. lo puedes repetir?¿

Saludos
__________________
*La amistad se multiplica cuando se divide*
  #8 (permalink)  
Antiguo 13/09/2007, 13:49
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Re: 5 y cambio

HOLA, la verdad es que no se me ocurria nada y puse este codigo.. aver si funciona.. no lo he probado porque mi servidor esta fallando..

fotos.php



<table width="536" height="1706" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="108" colspan="3" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<!--DWLayoutTable-->
<tr>
<td width="520" height="14"></td>
</tr>
<tr>
<td height="46" valign="top"><div align="center">

<?
@$codigo = $_GET['codigo'];
@mysql_connect('localhost',bd','pass') or die('No se puede conectar con el servidor');
mysql_select_db("bd");
$codigo = $_GET['codigo'];
@mysql_select_db('fotos') or die('No se puede seleccionar la base de datos especificada');
$resultado = @mysql_query("SELECT imagen,tipo,id FROM subir_imagenes WHERE nombre = '$codigo'");
$width = 654;
?>
<table width='534' height='510' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td height='19' colspan='2' align='left' valign='top'>

<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='523' height='19' valign='top'> <div align='right'><a href='javascript:history.back()'>&lt;--
Atrás</a></div></td>
</tr>
</table></td>


<td width='36'></td>
</tr>
<tr>
<td width='16' height='281'>&nbsp;</td>
<td width='536' valign='top'>


<!--Esta-->
<table width='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='#FFFFD2'>
<tr>
<td width='90' height='36'>&nbsp;</td>
<!--Parte-->
<?
$cols = 9;
?>
<td colspan='<?php echo $cols; ?>
' valign='top' bgcolor='#FFFFD2'>
<div align='center'>
<p align='center'><font size='2'><font size='2' face='Gill Sans MT'><font color='#000000' size='-1' face='Gill Sans MT'>
<br>
</font></font></font></p>
</div></td>
</tr>
<tr>
<td height='14'></td>
<td width='1'></td>
<td width='101'></td>
<td width='13'></td>
<td width='101'></td>
<td width='9'></td>
<td width='101'></td>
<td width='14'></td>
<td width='101'></td>
<td width='55'></td>
</tr>
<tr>
<?
//mostramos los registros
while ($row = mysql_fetch_array($resultado)) {
$cols = 9;
$nombre = $row["nombre"];
$id = $row["id"];
if ($cols >= 10) {
echo "<tr></tr>";
}
else {
echo "

<td height='107'></td>
<td colspan='6' valign='top'><a href='ver.php?id=$id'><img src='ver.php?id=$id' width='112' height='107' border='0'></a></td><br>
<td>&nbsp;</td>";
}
}
?>
</tr>
<tr>
<td height='17'></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height='107'></td>
<td>&nbsp;</td>
<td valign='top'><!--DWLayoutEmptyCell-->&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td></td>
<td></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

SALUDOS... USTEDES CREEN QUE FUNCIONE... O QUE ME RECOMIENDAN?

SALUDOS Y GRACIAS
__________________
*La amistad se multiplica cuando se divide*
  #9 (permalink)  
Antiguo 13/09/2007, 15:32
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Re: 5 y cambio

Hola.. alguien sabe?¿

Saludos
__________________
*La amistad se multiplica cuando se divide*
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:45.