Ver Mensaje Individual
  #16 (permalink)  
Antiguo 04/04/2013, 05:00
db87
 
Fecha de Ingreso: marzo-2013
Mensajes: 11
Antigüedad: 11 años, 1 mes
Puntos: 0
Respuesta: Bucle dentro de bucle ¿es posible?

Tienes razon!!!! ya he corregido las sentencias y he metido el SELECT de documentos en el While de notas y ahora no me sale ningun error... pero me sale la pagina completamente en blanco!! y eso que he puesto el echo tanto en Nota como en Documentos (cosa que tambien se me habia pasado...) no se si es que el echo no se esta ejecutando bien o no se estan obteniendo los datos...


Código PHP:
<?php require_once('../connections/gestion_hydba.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;
}
}

$varTarea_tareas "0";
if (isset(
$_GET["q"])) {
  
$varTarea_tareas $_GET["q"];
}
mysql_select_db($database_gestion_hydba$gestion_hydba);
$query_tareas sprintf("SELECT * FROM db_tareas WHERE db_tareas.tarea_id = %s"GetSQLValueString($varTarea_tareas"int"));
$tareas mysql_query($query_tareas$gestion_hydba) or die(mysql_error());
$row_tareas mysql_fetch_assoc($tareas);
$totalRows_tareas mysql_num_rows($tareas);

// primero la conexion tal cual de los comentarios 
mysql_select_db($database_gestion_hydba$gestion_hydba); 
$query_notas "SELECT * FROM db_tareas_notas ORDER BY db_tareas_notas.nota_crono DESC "
$notas mysql_query($query_notas$gestion_hydba) or die(mysql_error()); 
$row_notas mysql_fetch_assoc($notas); 
$totalRows_notas mysql_num_rows($notas); 
?>





<?php 

$n 
0
while(isset(
$row_notas[$n])){ 
/* AQUI POR EJEMPLO EL HTML QUE MONTA LA NOTA EN SI */ 
// para obtener los datos debes referirte a $row_notas[$n]['nombredelcampoquequieras'] 
    
echo $row_notas[$n]['nota_contenido'];
    
// por cada uno de los comentarios, obten los adjuntos.  
// fijate que te he cambiado un poco la sentencia sql 
mysql_select_db($database_gestion_hydba$gestion_hydba); 
$query_documentos "SELECT * FROM db_documentos WHERE documento_nota = " $row_notas[$n]['nota_id']; 
$documentos mysql_query($query_documentos$gestion_hydba) or die(mysql_error()); 
$row_documentos mysql_fetch_assoc($documentos); 
$totalRows_documentos mysql_num_rows($documentos);

// ahora solo hay que recorrer el array resultante y mostrar lo requerido 

     
$d 0
     while(isset(
$row_documentos[$d])){ 
/* AQUI EL HTML QUE MONTA LOS ADJUNTOS */ 
// para acceder a los datos debes referirte a $row_documentos[$d]['nombredelcampoquequieras'] 
    
echo $row_documentos[$d]['documento_archivo'];
         
         
$d++; 
    } 
      
     unset(
$row_documentos); 
     unset(
$totalRows_documentos); 
     
$n++;
}

?>



<?php
mysql_free_result
($tareas);
?>