Ver Mensaje Individual
  #6 (permalink)  
Antiguo 30/05/2008, 09:33
otto1303
 
Fecha de Ingreso: noviembre-2006
Ubicación: Evergreen Street
Mensajes: 239
Antigüedad: 17 años, 5 meses
Puntos: 2
Respuesta: Galería de fotos con imágenes horizontales y verticales

Bueno lo he subido a este sitio, por supuesto es solo una prueba, ya que los contenidos serán otros:

http://blog13.000webhost.info/carrito/index.php

El ejercicio que estoy haciendo era inicialmente de un carrito de compras que encontré en http://videotutoriales.es/mas-ejemplos.htm, donde empieza desde crear la Base de datos, definir el sitio, crear plantilla, hacer listado de productos, detalle del producto, pero allí terminó, ya no han seguido.

Entonces se me ocurrió hacer una galería para mi sitio web.

El código del archivo que lista las imágenes es:


<?php require_once('Connections/Carrito1.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_listado = 3;
$pageNum_listado = 0;
if (isset($_GET['pageNum_listado'])) {
$pageNum_listado = $_GET['pageNum_listado'];
}
$startRow_listado = $pageNum_listado * $maxRows_listado;

mysql_select_db($database_Carrito1, $Carrito1);
$query_listado = "SELECT * FROM fotos_mias";
$query_limit_listado = sprintf("%s LIMIT %d, %d", $query_listado, $startRow_listado, $maxRows_listado);
$listado = mysql_query($query_limit_listado, $Carrito1) or die(mysql_error());
$row_listado = mysql_fetch_assoc($listado);

if (isset($_GET['totalRows_listado'])) {
$totalRows_listado = $_GET['totalRows_listado'];
} else {
$all_listado = mysql_query($query_listado);
$totalRows_listado = mysql_num_rows($all_listado);
}
$totalPages_listado = ceil($totalRows_listado/$maxRows_listado)-1;

$queryString_listado = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_listado") == false &&
stristr($param, "totalRows_listado") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_listado = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_listado = sprintf("&totalRows_listado=%d%s", $totalRows_listado, $queryString_listado);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/carrito.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Documento sin t&iacute;tulo</title>
<!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style></head>

<body>
<table width="100%" border="0">
<tr>
<td>Aqui va el Logo </td>
</tr>
<tr>
<td align="center"><table width="85%" border="0">
<tr align="center">
<td><a href="index.php">INICIO</a></td>
<td>CARRITO</td>
<td>ACERCA DE </td>
<td>CONTACTO</td>
</tr>
</table></td>
</tr>
<tr>
<td><!-- InstanceBeginEditable name="Edicion" -->
<h2 align="center">Listado de Fotos</h2>
<?php do { ?>

<table width="59%" border="0" align="center">
<tr>
<td height="79" align="center" valign="middle"><div align="center"><a href="detalle.php?foto_id=<?php echo $row_listado['foto_id']; ?>"><img src="chiki/th_<?php echo $row_listado['nombre']; ?>" width="150" height="150" border="0"></a></div></td>
</tr>
<tr>
<td height="16" align="center" valign="middle"><div align="center"><?php echo $row_listado['descripcion']; ?></div></td>
</tr>
<tr>
<td align="center" valign="middle"><div align="center">Costo Q. <strong><?php echo $row_listado['precio']; ?>.00</strong></div></td>
</tr>
</table>
<?php } while ($row_listado = mysql_fetch_assoc($listado)); ?>
<p>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center">
<?php if ($pageNum_listado > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, 0, $queryString_listado); ?>">Primero</a>
<?php } // Show if not first page ?>
</td>
<td width="31%" align="center">
<?php if ($pageNum_listado > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, max(0, $pageNum_listado - 1), $queryString_listado); ?>">Anterior</a>
<?php } // Show if not first page ?>
</td>
<td width="23%" align="center">
<?php if ($pageNum_listado < $totalPages_listado) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, min($totalPages_listado, $pageNum_listado + 1), $queryString_listado); ?>">Siguiente</a>
<?php } // Show if not last page ?>
</td>
<td width="23%" align="center">
<?php if ($pageNum_listado < $totalPages_listado) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, $totalPages_listado, $queryString_listado); ?>">&Uacute;ltimo</a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>

</p>
<p>&nbsp; </p>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($listado);
?>

La estructura de la Base de datos es:


CREATE TABLE IF NOT EXISTS `fotos_mias` (
`foto_id` int(11) NOT NULL auto_increment,
`lugar` varchar(100) collate latin1_general_ci NOT NULL default '',
`nombre` varchar(100) collate latin1_general_ci NOT NULL default '',
`descripcion` varchar(900) collate latin1_general_ci NOT NULL,
`precio` double NOT NULL default '0',
`hits` varchar(50) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`foto_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=21 ;

Inicialmente el tipo de campo de descripción era blow, pero a la hora de querer modificar un dato desde phpMyAdmin solo se veían códigos y lo cambié a varchar. Agregué unc campo hits para contar la canitidad de veces que ha sido vista la foto, pero no sé como hacerlo, ya puse otro post con esta duda (en php), alguien me decía que un contador y un update, pero no sé cómo generar el código.

Agradezco a los que se han tomado la molestia de contestarme.

Última edición por otto1303; 30/05/2008 a las 09:46