Ver Mensaje Individual
  #5 (permalink)  
Antiguo 22/08/2013, 19:36
gabymar
 
Fecha de Ingreso: agosto-2008
Mensajes: 94
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: generar reportes dinamicamente

Hola a continuacion mi codigo funciona perfecto, genera una tabla con los campos seleccionados por checkbox.
Código PHP:
 <form  method="post" name="reporte" action="reporte.php" >
    <p>&nbsp;</p>
    <table width="786" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000066">
  <tr>
<td width="196" align="center"><div align="left"><span class="Estilo3">NOMBRE_CAMPO1
  <input name="combo1" type="checkbox" style="width:15px;" value="NOMBRE_CAMPO1"  />
</span></div></td>

<td width="181" align="center"><div align="left"><span class="Estilo3">NOMBRE_CAMPO2
  <input name="combo2" value="NOMBRE_CAMPO2" type="checkbox" style="width:15px;" />
</span></div></td>
</tr></table>
<?
$x
=0
if(
$_POST['combo1']!="")
{
$combo1=$_POST['combo1'];
$cc1=1;
$x=1
}
else{
$combo1="";
$cc1=0;
}

if(
$_POST['combo2']!="") { //SE ULITILIZA PARA DETERMINAR SI EL CAMPO SELECCIONADO TIENE UN CAMPO ANTERIOR SELECCIONADO
    
if ($x==1) { 
    
$combo2=",".$_POST['combo2'];}
    else{
    
$combo2=$_POST["combo2"];
    
$x=1;} //SE ULITILIZA PARA DETERMINAR SI EL CAMPO SELECCIONADO TIENE UN CAMPO ANTERIOR SELECCIONADO
  
$cc2=1;
}
else{
$combo2="";
$cc2=0;
}
?>       
     <table width="47%" border="1" CELLPADDING="0" CELLSPACING="0" align="center" bordercolor="#000066">       
     <tr>
    <?  if ($cc1==1){ ?>
     <td width="29" align="center"><span class="Estilo7 Estilo3">NOMBRE_CAMPO1</span></td>
     <? ?>
      <?  if ($cc2==1){ ?>
     <td width="29" align="center"><span class="Estilo7 Estilo3">NOMBRE_CAMPO1</span></td>
     <? ?>
     </tr>
<? 
$con
='SELECT DISTINCT ';////SE CONCATENA LOS CAMPOS QUE HAYAN SIDO SELECCIONADOS

     
if ($cc1==1){       
     
$consulta1=$consulta1 $combo1." ";}    
     if (
$cc2==1){ 
     
$consulta1=$consulta1 .$combo2." ";}
        
    
$con=$con "FROM TABLA ";
    
$resmysql_query($cons$conexionn)or die(mysql_error());
    while(
$rowmysql_fetch_array($res)) {
      
?>
    <tr>   
      <?  if ($cc1==1){ ?>////IMPRIMO LOS REGISTROS DE LOS CAMPOS PARA ELLO SE HACE EL IF
     <td width="29" align="center"><? echo"$row[NOMBRE_CAMPO1]";}?> </td>
      <?  if ($cc2==1){ ?>
     <td width="29" align="center"><? echo"$row[NOMBRE_CAMPO2]";}?></td>
    <? 
    
}//fin del while
    
?></table>
<? 
  
// fin de enviar 
}    
?>
</form>