![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
04/12/2008, 11:08
|
| | Fecha de Ingreso: septiembre-2008 Ubicación: Nuñez, Capital Federal
Mensajes: 423
Antigüedad: 16 años, 5 meses Puntos: 1 | |
Respuesta: Listar consulta en horizontal A ver si pongo todo el codigo, puedes ver donde está el error... lo que tengo es (oq uiero tener) es un listado de registros, 3 por columnas, y un maxim de 9 por fila.. o sea... tendria que aparecer el registro 10 en la segunda hoja, etc.. pero ma aparece el 11. Y en la primera a partir del 2, y asi. Me salte un registro. Este es el codigo: Código PHP: <?php require_once('../../Connections/final.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_curricular = 9;
$pageNum_curricular = 0;
if (isset($_GET['pageNum_curricular'])) {
$pageNum_curricular = $_GET['pageNum_curricular'];
}
$startRow_curricular = $pageNum_curricular * $maxRows_curricular;
mysql_select_db($database_final, $final);
$query_curricular = "SELECT * FROM proyectos";
$query_limit_curricular = sprintf("%s LIMIT %d, %d", $query_curricular, $startRow_curricular, $maxRows_curricular);
$curricular = mysql_query($query_limit_curricular, $final) or die(mysql_error());
$row_curricular = mysql_fetch_assoc($curricular);
if (isset($_GET['totalRows_curricular'])) {
$totalRows_curricular = $_GET['totalRows_curricular'];
} else {
$all_curricular = mysql_query($query_curricular);
$totalRows_curricular = mysql_num_rows($all_curricular);
}
$totalPages_curricular = ceil($totalRows_curricular/$maxRows_curricular)-1;
$titulo= $row_curricular['nombre'];
mysql_select_db($database_final, $final);
$query_fotos = "SELECT imagenes.nombre, imagenes.id_proyecto FROM imagenes, proyectos";
$fotos = mysql_query($query_fotos, $final) or die(mysql_error());
$row_fotos = mysql_fetch_assoc($fotos);
$totalRows_fotos = mysql_num_rows($fotos);
$queryString_curricular = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_curricular") == false &&
stristr($param, "totalRows_curricular") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_curricular = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_curricular = sprintf("&totalRows_curricular=%d%s", $totalRows_curricular, $queryString_curricular);
?>
<?php require_once('../../Connections/proyecto.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>
<title>Ingresar Proyectos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script src="../../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
</head>
<body><div align="center">
<table>
<tr>
<td><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td class="titulo">Ingresar Proyecto de Investigación Extracurricular</td>
</tr>
<tr>
<td class="titulo"> </td>
</tr>
<tr>
<?php do { ?>
<?
echo '<table width="100%" align=center>';
$columnes = 3; # Número de columnas (variable)
if (($rows=mysql_num_rows($curricular))==0) {
echo '<tr><td colspan=$columnes>No hay resultados en la BD.</td></tr> ';
} else {
echo '<tr><td colspan=$columnes>Proyectos ingresados </td></tr>';
}
for ($i=0; $row = mysql_fetch_row ($curricular); $i++) {
$resto = ($i % $columnes); # Número de celda del <tr> en que nos encontramos
if ($resto == 1) {echo "<tr>";} # Si es la primera celda, abrimos <tr>
echo '<td width="33%"><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td class="proyecto">'. $row[1]. " ". $row[0]. '</td>
</tr>
<tr>
<td><div align="center"><img src="" alt="" name="foto" width="250" height="180" id="foto" /></div></td>
</tr>
<tr>
<td class="texto">Detalles</td>
</tr>
</table></td>';
if ($resto == 0) {echo "</tr>";} # 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++) {echo "<td> </td>";}
echo "</tr>"; # Cerramos la última línea </tr>
}
mysql_close($final);
echo "</table>"; ?>
<?php } while ($row_curricular = mysql_fetch_assoc($curricular)); ?>
<table border="0">
<tr>
<td><?php if ($pageNum_curricular > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_curricular=%d%s", $currentPage, 0, $queryString_curricular); ?>">First</a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_curricular > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_curricular=%d%s", $currentPage, max(0, $pageNum_curricular - 1), $queryString_curricular); ?>">Previous</a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_curricular < $totalPages_curricular) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_curricular=%d%s", $currentPage, min($totalPages_curricular, $pageNum_curricular + 1), $queryString_curricular); ?>">Next</a>
<?php } // Show if not last page ?></td>
<td><?php if ($pageNum_curricular < $totalPages_curricular) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_curricular=%d%s", $currentPage, $totalPages_curricular, $queryString_curricular); ?>">Last</a>
<?php } // Show if not last page ?></td>
</tr>
</table>
</tr>
</table></td>
</tr>
<tr>
<td style="background-repeat:no-repeat; background-position:center" background="../imagenes/abajo.gif" height="28"><div align="center" class="copy" style="background-repeat:no-repeat; background-position:center; font-family: 'Lucida Grande'; font-size: 10px; color: #FFF;">Copyright 2008, <strong>Proyectoshuerto.com.ar</strong> - Todos los derechos reservados. Prohibida la reproducción total o parcial de este sitio sin previo consentimiento de los autores y/o dueños del sitio. <strong> | Contacto:</strong><em>[email protected]</em></div></td>
</tr>
</table></div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($curricular);
mysql_free_result($fotos);
?> Si encuentran donde puede estar el error, estaré muy agradecido!!
saludos,
pablo
pd: y que era lo que quedaba más limpio? en que parte? gracias! |