Buahh!!! muchisimas gracias Sevillacode!!
tiene muy buena pinta! pero creo que me estoy dejando algo...
cuando ejecuto me da el error " $n++: "
...he probado de cambiar " $n++: " por " $n++; " y entonces pasa a darme error en:
Código PHP:
$query_notas = sprintf("SELECT * FROM db_tareas_notas WHERE db_tareas_notas.nota_tarea = %s ORDER BY db_tareas_notas.nota_crono DESC",
y en:
Código PHP:
$query_documentos = "SELECT DISTINCT * FROM db_documentos d, db_tareas_notas t WHERE d.documento_nota = " . $row_notas[$n]['nota_id'];
ufff algo se me escapaaaa
Este es el codigo completo:
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 = sprintf("SELECT * FROM db_tareas_notas WHERE db_tareas_notas.nota_tarea = %s ORDER BY db_tareas_notas.nota_crono DESC", GetSQLValueString($varNota_notas, "int"));
$notas = mysql_query($query_notas, $gestion_hydba) or die(mysql_error());
$row_notas = mysql_fetch_assoc($notas);
$totalRows_notas = mysql_num_rows($notas);
// 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 DISTINCT * FROM db_documentos d, db_tareas_notas t WHERE d.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);
?>
<?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']
$row_notas[$n]['nota_contenido'];
// 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']
$row_documentos[$d]['documento_archivo'];
$d++;
}
unset($row_documentos);
unset($totalRows_documentos);
$n++:
}
?>
<?php
mysql_free_result($tareas);
?>