|    
			
				06/03/2008, 08:53
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: enero-2008 
						Mensajes: 33
					 Antigüedad: 17 años, 9 meses Puntos: 0 |  | 
  |  Re: consulta mysql y mostrar por pantalla  
  Lo que deseo es mostrar en una tabla los datos de la factura y en las 2 ultimas columnas mostrar el nombre de los responsables de cada factura.
 todo esto en una sola pagina
 
 tengo el siguiente codigo:
 
 <?php
 
 // LLAMANDO AL MODULO DE CONEXION
 include("../php/modulo_conexion.php");
 
 // ESTABLECIENDO LA CONEXION
 $cnn = mysql_connect($servidor,$usuario,$password);
 if(!isset($cnn)){
 die ("Error de conexión: ").mysql_error();
 }
 
 // SELECCIONANDO LA BASE DE DATOS
 mysql_select_db($database,$cnn);
 
 //$sql = "SELECT * FROM facturas ORDER BY fact_fech_ingr";
 
 $sql_final = "SELECT facturas.fact_nume, facturas.proveedores_prove_rut, facturas.cuentas_cuen_codi,
 facturas.fact_fech_ingr, facturas.fact_desc, facturas.fact_monto, facturas.fact_fech_envi,
 roles.rol_desc
 FROM facturas, asignacion, roles
 WHERE facturas.fact_nume = asignacion.facturas_fact_nume
 AND roles on roles.rol_codi = asignacion.roles_rol_codi";
 
 $resultado = mysql_query($sql_final,$cnn);
 echo mysql_error();
 
 // codigo responsable
 $codigo_resp = 0;
 $responsable = 0;
 
 $contador = 0;
 
 $facturas = array();
 
 // DEFINIENDO UNA TABLA PARA MOSTRAR LOS DATOS LAS FACTURAS
 echo "<center>";
 echo "<table border='2' bgcolor='#e3e4fa'>\n";
 echo "<tr> \n";
 echo "<td><b>Número de Factura</b></td> \n";
 echo "<td><b>Rut del Proveedor</b></td> \n";
 echo "<td><b>Código de Cuenta Contable</b></td> \n";
 echo "<td><b>Fecha de Ingreso</b></td> \n";
 echo "<td><b>Descripción</b></td> \n";
 echo "<td><b>Monto</b></td> \n";
 echo "<td><b>Fecha de Envío</td></b> \n";
 echo "<td><b>Responsable de Gasto</td></b> \n";
 echo "</tr> \n";
 echo "</center>";
 
 while($row = mysql_fetch_array($resultado)){
 
 // CAMBIANDO EL FORMATO DE LA FECHA DE AAAA-MM-DD a DD-MM-AAAA
 $f1 = substr($row["fact_fech_ingr"],0,4);
 $f2 = substr($row["fact_fech_ingr"],5,2);
 $f3 = substr($row["fact_fech_ingr"],8,2);
 $fecha_ingreso = $f3."-".$f2."-".$f1;
 
 // COMPROBANDO SI EL CODIGO DE CUENTA Y LA FECHA DE ENVIO
 // TIENEN VALOR  NULL. DE SER ASI, MUESTRA UN MENSAJE
 // DE QUE NO ESTÁ INGRESADO EL DATO.
 if($row['cuentas_cuen_codi'] == NULL){
 $row['cuentas_cuen_codi'] = "<b> No Ingresada </b>";
 }
 
 if($row['fact_fech_envi'] == NULL or $row['fact_fech_envi'] == "0000-00-00"){
 $row['fact_fech_envi'] = "<b> No Ingresada <b>";
 }
 
 ?>
 
 <html>
 <head>
 
 <title> Consulta de Facturas - UNIVERSIA CHILE </title>
 
 <!-- ENLAZANDO HOJAS DE ESTILO -->
 <link href="../css/estilo_tablas.css" rel="stylesheet" rev="stylesheet" type="text/css">
 
 <!-- LLAMADA A LAS FUNCIONES JAVASCRIPT -->
 <script src="../js/validar_codificacion.js" type="text/javascript"></script>
 
 </head>
 
 <body>
 
 <form id="f" method="post">
 
 <center>
 
 <!-- CONTINUACION TABLA -->
 <tr>
 <td class="estilo1" > <?php echo $row['fact_nume']; ?> </td>
 <td class="estilo1" > <?php echo $row['proveedores_prove_rut']; ?> </td>
 <td class="estilo1" > <?php echo $row['cuentas_cuen_codi']; ?> </td>
 <td class="estilo1" > <?php echo $fecha_ingreso ?> </td>
 <td class="estilo1" > <?php echo $row['fact_desc']; ?> </td>
 <td class="estilo1" > <?php echo "$ ".$row['fact_monto']; ?> </td>
 <td class="estilo1" > <?php echo $row['fact_fech_envi']; ?> </td>
 <td class="estilo1" > <?php echo $row['roles_desc']; ?> </td>
 </tr>
 
 <?php
 //} // FIN WHILE RESPONSABLES
 } // FIN WHILE FACTURAS
 mysql_close($cnn);
 ?>
 
 </table>
 
 <br>
 
 </center>
 
 </form>
 
 </body>
 
 </html>
   Última edición por barto3x; 06/03/2008 a las 08:59
     |