Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/03/2011, 03:29
Avatar de aalleexx81
aalleexx81
 
Fecha de Ingreso: noviembre-2009
Mensajes: 153
Antigüedad: 14 años, 5 meses
Puntos: 0
Pregunta Respuesta: Problema al ejecutar sentencia

Aquí está el código completo. Al imprimir las dos consultas, veo que son exactamente iguales. Pero la única que funciona es a la que se le pasa la constante 5.

Código PHP:
<?php

$grupo 
"<script> document.write(perfil) </script>";
//echo "GRUPO = $grupo<br>";

echo '
<table border=1>
    <tr>
        <th>B/D</th>
        <th>TP</th>
        <th>Petici&oacute;n</th>
        <th>F. Aviso</th>
        <th>Centro</th>
        <th>Asunto</th>
        <th>Asignaci&oacute;n</th>
        <th>Usuario</th>
        <th>F. Prevista</th>
        <th>P</th>
        <th>A/F</th>
     </tr>'
;
 
     
$q "select * from t_peticiones LEFT JOIN t_t_peticion on id_tipopeticion = id_t_peticion where id_perfil = 5 order by f_alta desc";
      
$q1 "select * from t_peticiones LEFT JOIN t_t_peticion on id_tipopeticion = id_t_peticion where id_perfil = $grupo order by f_alta desc";

     echo 
"Consulta1: $q<br>Consulta2: $q1<br>";

     
$resq mysql_query($q);
     
     while(
$rowq mysql_fetch_array($resq)){
         
        if(
$rowq['id_usuario'] != ""){
        
            
$qusu "select nom_usuario from t_usuarios where id_usuario = ".$rowq['id_usuario'];
            
            
$resqusu mysql_query($qusu);
            
$rowqusu mysql_fetch_array($resqusu);
            
$idusuario $rowqusu['nom_usuario'];
        }    
        else{
            
            
$idusuario "-------";
        }    
                
        
$qg "select n_perfil from t_perfiles where id_perfil = 5";
        
        
$resqg mysql_query($qg);
        
$rowqg mysql_fetch_array($resqg);
        
        
$estado "select nom_estado from t_estado_pet where id_estado = ".$rowq['id_estado'];    

        
$resestado mysql_query($estado);
        
$rowestado mysql_fetch_array($resestado);
            
        if(
$rowestado['nom_estado']== "FINALIZADO")
            
$est "./images/ico/Finalizada.png";
        else{ 
            if(
$rowestado['nom_estado']!="PDTE. ACEPTACIÓN")    
                
$est "./images/ico/Abierta.png";
        }        

         echo 
'<tr>
                <td>'
;
                       
                       if(
$rowq['bloqueado'] != 1
                        echo 
'<img src="./images/ico/2BotonBloqOff.png"/></td>';
                    else 
                        echo 
'<img src="./images/ico/2BotonDesbloqOff.png"/></td>';
        echo
'            
               <td>'
.$rowq['cod_t_peticion'].'</td>
               <td><a href="javascript:ventanaSecundaria3(\'inf_det_peticion.php?peti='
.$rowq['id_peticion'].'\')">'.$rowq["id_peticion"].'</a></td>
               <td>'
.substr($rowq["f_alta"],0,10).'</td>
               <td>¿Centro?</td>
               <td align="center"><a href="javascript:ventanaDetalle(\'det_peticion.php?i='
.$rowq['id_peticion'].'\')")><img src="./images/ico/2info.png" border=0/></a>&nbsp;&nbsp;'.str_replace("+"," "substr($rowq["asunto"],0,15)).'...</td>
               <td>'
.$rowqg['n_perfil'].'</td>
               <td>'
.$idusuario.'</td>
               <td>'
.substr($rowq["f_limite"],0,10).'</td>
               <td>'
.$rowq["id_prioridad"].'</td>
               <td><img src="'
.$est.'"></td>
               </tr>'
;
    }
    
echo 
'</table>';

echo 
'<br><br>';

?>