Tengo una consulta en la cual en el while de dicha consulta hago otra subconsulta pero no trae nada.
¿Podrían ver que esta mal en el código que no trae nada? De hecho no pasa por el primer while.
function datos(){
$opcion=$this->opcion;
$fila="";
$dias="";
if ($opcion=="todo") {
echo "entre al if";
$sql="SELECT count(e.RUT_PARTICIPANTE) as cantidad,cg.NOMBRE_CURSO,cg.COSTO,cu.ID_CURSO_UNICO,cu.DURACION_H,cu.JORNADA_H,
cu.CANTIDAD_PARTICIPANTES,cu.fecha_inicio,cu.fecha_termino,cu.HORA_DESDE,cu.HORA_HASTA,c.nombre_comuna,cu.RUT_RELATOR,nombre_estado
from participanes p, enrolamiento e,curso_unico cu,curso_generico cg,comunas c,estado_curso ec
where p.RUT_PARTICIPANTE=e.RUT_PARTICIPANTE
AND c.id_comuna=cu.id_comuna
AND cg.ID_CURSO=cu.ID_CURSO
AND cu.ID_CURSO_UNICO=e.ID_CURSO_UNICO
AND ec.id_estado_curso=cu.id_estado_curso";
$stmt=$this->conexion->prepare($sql);
if (!$stmt) {
echo $this->conexion->error;
}
$stmt->bind_result($cantidad,$n_curso,$costo,$id_curso,$duracion,$jornada,$can_part,$f_inicio,$f_termino,$h_desde,$h_hasta,$comuna,$relator,$estado);
$stmt->execute();
$stmt->store_result();
$stmt->free_result();
while($stmt->fetch()){
$stmt1=$this->conexion->prepare("SELECT d.nombre FROM curso_dias cd, dias d where cd.num_dia=d.num_dia and cd.ID_CURSO_UNICO=?");
if (!$stmt1) {
echo $this->conexion->error;
}
$stmt1->bind_param('i',$id_curso);
$stmt1->bind_result($nombre);
$stmt1->execute();
$stmt1->store_result();
while ($stmt1->execute()) {
$dias="$nombre,";
}
$stmt1->close();
$horario=$dias."<br>desde:$h_desde hasta:$h_hasta";
$fila.="<tr>
<td>$id_curso</td>
<td>$relator</td>
<td>$duracion</td>
<td>$jornada</td>
<td>$$cant_part</td>
<td>$f_inicio</td>
<td>$$f_termino</td>
<td>$horario</td>
<td>$estado</td>
</tr>";
$dias="";
echo $id_curso;
}
$stmt->close();
}
return $fila;
}
var_dump($stmt)
para ver si está devolviendo resultados o no?