Ver Mensaje Individual
  #5 (permalink)  
Antiguo 13/02/2013, 23:23
Avatar de CMushroom
CMushroom
 
Fecha de Ingreso: diciembre-2011
Ubicación: Morelos
Mensajes: 99
Antigüedad: 13 años, 3 meses
Puntos: 1
Respuesta: Componer query de filtro para consulta

Código PHP:
<?php
include("Conexion.php");    

if(isset(
$_GET['page']))
    {
    
$pagina $_GET['page'];
    }                
else
    {
    
$pagina 1;
    }    
$Matricula 0
$Licenciatura 0
$Semestre 0;
$Grupo 0
$Turno 0
$Sexo 0
if (isset(
$_POST["Matricula"]))
    {
    
$Matricula $_POST["Matricula"]; 
    }
if (isset(
$_POST["Licenciatura"])) 
    {
    
$Licenciatura $_POST["Licenciatura"]; 
    } 
if (isset(
$_POST["Semestre"]))
    {
    
$Semestre $_POST["Semestre"];
    }
if (isset(
$_POST["Grupo"])) 
    {
    
$Grupo $_POST["Grupo"]; 
    }
if (isset(
$_POST["Turno"]))
    {
    
$Turno $_POST["Turno"]; 
    }
if (isset(
$_POST["Sexo"])) 
    {
    
$Sexo $_POST["Sexo"]; 
    }                  
$criterios "";
if (
$Matricula != 0)
    {
    
$criterios .= "&& alumnos.IdAlumno = ".$Matricula." ";
    }
if (
$Licenciatura != 0
    {
    
$criterios .= " && alumnos.ClaveLicenciatura = ".$Licenciatura." ";
    }    
if (
$Grupo != 0
    {
    
$criterios .= " && alumnos.IdGrupo = ".$Grupo ." ";
    }
if (
$Semestre != 0
    {
    
$criterios .= " && alumnos.IdGrupo = ".$Semestre." ";
    }
if (
$Turno != 0
    {
    if(
$Turno==1)$Turno "Matutino";
    if(
$Turno==2)$Turno "Vespertino";
    
$criterios .= " && alumnos.Turno = '".$Turno."' ";
    }
if (
$Sexo != 0
    {
    if(
$Sexo==1)$Sexo "Masculino";
    if(
$Sexo==2)$Sexo "Femenino";
    
$criterios .= " && alumnos.sexo = '".$Sexo."' ";
    }    
@
$consulta 'SELECT * FROM alumnos, creditos, cursos, examen_medca WHERE alumnos.IdAlumno = creditos.IdAlumno && alumnos.IdAlumno = cursos.IdAlumno && alumnos.IdAlumno = examen_medca.IdAlumno '.$criterios.'';    
$datos mysql_query($consulta,$conexion);                

echo 
"<br>".$consulta."<br><br>";
?>
<div id="galleria">  
<?php              
@$numerofilas mysql_num_rows($datos);            
@
$filasporpagina 100;            
$ultimapagina ceil($numerofilas $filasporpagina);            
$pagina = (int)$pagina;

if(
$pagina $ultimapagina)
    {
    
$pagina $ultimapagina;
    }
if(
$pagina 1)
    {
    
$pagina 1;
    }    
$limite 'SELECT * FROM alumnos, creditos, cursos, examen_medca WHERE alumnos.IdAlumno = creditos.IdAlumno && alumnos.IdAlumno = cursos.IdAlumno && alumnos.IdAlumno = examen_medca.IdAlumno '.$criterios.' LIMIT '.($pagina -1) * $filasporpagina ',' .$filasporpagina;    
                                    
$consulta $limite;
$registro=mysql_query($consulta);
            
if(!
$registro)
    {
    die(
'Consulta invalida ' mysql_error());
    }
else
    {
    
?>
    <br /><center>
    <div style=" height: 260px; width: 730px; overflow: auto; ">
    <br /><table class="table1";><thead>
        <tr>
            <th scope="col" abbr="Deluxe">IdAlumno</th>
            <th scope="col" abbr="Deluxe">Cre_Cult1_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Cult1</th>
            <th scope="col" abbr="Deluxe">Cre_Cult1_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Cult2_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Cult2</th>
            <th scope="col" abbr="Deluxe">Cre_Cult2_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Cult3_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Cult3</th>
            <th scope="col" abbr="Deluxe">Cre_Cult3_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Cult4_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Cult4</th>
            <th scope="col" abbr="Deluxe">Cre_Cult4_imag</th>     
            <th scope="col" abbr="Deluxe">Cre_Acad1_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Acad1</th>
            <th scope="col" abbr="Deluxe">Cre_Acad1_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Acad2_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Acad2</th>
            <th scope="col" abbr="Deluxe">Cre_Acad2_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Acad3_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Acad3</th>
            <th scope="col" abbr="Deluxe">Cre_Acad3_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Acad4_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Acad4</th>
            <th scope="col" abbr="Deluxe">Cre_Acad4_imag</th>   
            <th scope="col" abbr="Deluxe">Cre_Depo1_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Depo1</th>
            <th scope="col" abbr="Deluxe">Cre_Depo1_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Depo2_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Depo2</th>
            <th scope="col" abbr="Deluxe">Cre_Depo2_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Depo3_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Depo3</th>
            <th scope="col" abbr="Deluxe">Cre_Depo3_imag</th>
            <th scope="col" abbr="Deluxe">Cre_Depo4_fecha</th>
            <th scope="col" abbr="Deluxe">Cre_Depo4</th>
            <th scope="col" abbr="Deluxe">Cre_Depo4_imag</th>
            <th scope="col" abbr="Deluxe">CIng1_fecha</th>
            <th scope="col" abbr="Deluxe">CIng1</th>
            <th scope="col" abbr="Deluxe">CIng1_imag></th>
            <th scope="col" abbr="Deluxe">CIng2_fecha</th>
            <th scope="col" abbr="Deluxe">CIng2</th>
            <th scope="col" abbr="Deluxe">CIng2_imag</th>
            <th scope="col" abbr="Deluxe">CIng3_fecha</th>
            <th scope="col" abbr="Deluxe">CIng3</th>
            <th scope="col" abbr="Deluxe">CIng3_imag</th>    
            <th scope="col" abbr="Deluxe">medca_fecha</th>
            <th scope="col" abbr="Deluxe">medca_obtenido</th>
            <th scope="col" abbr="Deluxe">medca_img</th>
        </tr></thead>             
            <?php
            
while($row mysql_fetch_array($registro))
                {  
                
?>
                <tr><td><?php echo $row['IdAlumno']; ?></td>    
                    <td><?php echo $row['Cre_Cult1_fecha']; ?></td>
                    <td><?php if($row['Cre_Cult1']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php $row['Cre_Cult1_imag']; ?>" title= "Credito Cultural 1">ver</a></td>  
                                                                                                                     
                    <td><?php echo $row['Cre_Cult2_fecha']; ?></td>
                    <td><?php if($row['Cre_Cult2']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php $row['Cre_Cult2_imag']; ?>" title= "Credito Cultural 2">ver</a></td> 
                    
                    <td><?php echo $row['Cre_Cult3_fecha']; ?></td>
                    <td><?php if($row['Cre_Cult3']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php $row['Cre_Cult3_imag']; ?>" title= "Credito Cultural 3">ver</a></td> 
                    
                    <td><?php echo $row['Cre_Cult4_fecha']; ?></td>
                    <td><?php if($row['Cre_Cult4']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Cult4_imag']; ?>" title= "Credito Cultural 4"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Acad1_fecha']; ?></td>
                    <td><?php if($row['Cre_Acad1']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Acad1_imag']; ?>" title= "Credito Academico 1"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Acad2_fecha']; ?></td>
                    <td><?php if($row['Cre_Acad2']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Acad2_imag']; ?>" title= "Credito Academico 2"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Acad3_fecha']; ?></td>
                    <td><?php if($row['Cre_Acad3']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Acad3_imag']; ?>" title= "Credito Academico 3"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Acad4_fecha']; ?></td>
                    <td><?php if($row['Cre_Acad4']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Acad4_imag']; ?>" title= "Credito Academico 4"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Depo1_fecha']; ?></td>
                    <td><?php if($row['Cre_Depo1']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Depo1_imag']; ?>" title= "Credito Deportivo 1"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Depo2_fecha']; ?></td>
                    <td><?php if($row['Cre_Depo2']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['Cre_Depo2_imag']; ?>" title= "Credito Deportivo 2"> ver</a></td> 
                    
                    <td><? echo $row['Cre_Depo3_fecha']; ?></td>
                    <td><?php if($row['Cre_Depo3']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<? echo $row['Cre_Depo3_imag']; ?>" title= "Credito Deportivo 3"> ver</a></td> 
                    
                    <td><?php echo $row['Cre_Depo4_fecha']; ?></td>
                    <td><?php if($row['Cre_Depo4']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<? echo $row['Cre_Depo4_imag']; ?>" title= "Credito Deportivo 4"> ver</a></td> 
                    
                    <td><?php echo $row['CIng1_fecha']; ?></td>
                    <td><?php if($row['CIng1']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<? echo $row['CIng1_imag']; ?>" title= "Taller Lectura y Redaccion"> ver</a></td> 
                    
                    <td><?php echo $row['CIng2_fecha']; ?></td>
                    <td><?php if($row['CIng2']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<? echo $row['CIng2_imag']; ?>" title= "Ingles 1"> ver</a></td> 
                    
                    <td><?php echo $row['CIng3_fecha']; ?></td>
                    <td><?php if($row['CIng3']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['CIng3_imag']; ?>" title= "Ingles 2"> ver</a></td> 
                    
                    <td><?php echo $row['medca_fecha']; ?></td>
                    <td><?php if($row['medca_obtenido']== "si"){?><span class="check"><?php }?></span></td>
                    <td><a href = "<?php echo $row['medca_img']; ?>" title= "Examen media carrera "> ver</a></td> 
              </tr>