Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/08/2009, 12:32
jonas_alvarado
 
Fecha de Ingreso: agosto-2009
Mensajes: 34
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Armar tabla en PHP

ok mi codigo es el siguiente :


// ************ consulta sql general *********
//
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename="nombre.xls"');
require '../../clases/Bd.clase.php';
$bd=Db::getInstance();
$sql= "SELECT ordenes.area_empresa,ordenes.sociedad,ordenes.agen cia,ordenes.cod_cep,ordenes.nombre_cliente
,ordenes.direccion_cliente,ordenes.persona_contact o,ordenes.tlf_cliente,ordenes.texto_aviso_1,ordene s.texto_aviso_2
,ordenes.marca,ordenes.modelo,ordenes.numero_inven tario,ordenes.numero_activo,ordenes.numero_serial_ fabricacion,ordenes.clase,
ordenes.descripcion_actividad,ordenes.numero_ods,o rdenes.fecha_inicio_extrema,ordenes.fecha_fin_extr ema,
ordenes.pto_trabajo_ejecutante,ordenes.status_ods, ordenes.texto_reparacion,ordenes.fecha_ejecucion,
ordenes.hora_inicio,ordenes.hora_fin,ordenes.id_re porte,producto_utilizado.id_producto,producto.desc ripcion,
producto_utilizado.cantidad_utilizada,producto.und _medida,tecnico.cod_almacen,producto_utilizado.lot e
FROM ORDENES INNER JOIN producto_utilizado ON producto_utilizado.id_reporte = ordenes.id_reporte
INNER JOIN TECNICO ON producto_utilizado.id_tecnico = tecnico.id
INNER JOIN PRODUCTO ON producto_utilizado.id_producto = producto.id";
$stmt=$bd->ejecutar($sql)or die(mysql_error());
echo "<table border=1>\n";
echo "<tr>\n";
echo "<th>AREA DE EMPRESA</th>\n";
echo "<th>SOCIEDAD</th>\n";
echo "<th>AGENCIA</th>\n";
echo "<th>CODIGO CEP</th>\n";
echo "<th>NOMBRE CLIENTE</th>\n";
echo "<th>DIRECCION</th>\n";
echo "<th>PERSONA CONTACTO</th>\n";
echo "<th>TELEFONO</th>\n";
echo "<th>TEXTO DEL AVISO 1</th>\n";
echo "<th>TEXTO DEL AVISO 2</th>\n";
echo "<th>MARCA</th>\n";
echo "<th>MODELO</th>\n";
echo "<th>NUMERO INVENTARIO</th>\n";
echo "<th>NUMERO ACTIVO</th>\n";
echo "<th>NUMERO SERIE FABRICANTE</th>\n";
echo "<th>CLASE</th>\n";
echo "<th>DESCRIPCION CLASE ACTIVIDAD</th>\n";
echo "<th>NUMERO ORDEN</th>\n";
echo "<th>FECHA INICIO EXTREMA</th>\n";
echo "<th>FECHA FIN EXTREMA</th>\n";
echo "<th>PTO TRABAJO EJECUTANTE</th>\n";
echo "<th>STATUS DE ORDEN</th>\n";
echo "<th>TEXTO DE REPARACION</th>\n";
echo "<th>FECHA EJECUCION</th>\n";
echo "<th>HORA INICIO</th>\n";
echo "<th>HORA FINAL</th>\n";
echo "<th>NUMERO REPORTE INTERNO</th>\n";
echo "<th>CODIGO MATERIAL</th>\n";
echo "<th>DESCRIPCION</th>\n";
echo "<th>CANTIDAD</th>\n";
echo "<th>UDM</th>\n";
echo "<th>ALMACEN</th>\n";
echo "<th>LOTE</th>\n";
echo "</tr>\n";
$i = 0;
do {
echo "<tr align=>\n";
echo "<td><div align=\"left\">".$row['area_empresa']."</div></td>\n";
echo "<td><div align=\"left\">".$row['sociedad']."</div></td>\n";
echo "<td><div align=\"left\">".$row['agencia']."</div></td>\n";
echo "<td><div align=\"left\">".$row['cod_cep']."</div></td>\n";
echo "<td><div align=\"left\">".$row['nombre_cliente']."</div></td>\n";
echo "<td><div align=\"left\">".$row['direccion_cliente']."</div></td>\n";
echo "<td><div align=\"left\">".$row['persona_contacto']."</div></td>\n";
echo "<td><div align=\"left\">".$row['tlf_cliente']."</div></td>\n";
echo "<td><div align=\"left\">".$row['texto_aviso_1']."</div></td>\n";
echo "<td><div align=\"left\">".$row['texto_aviso_2']."</div></td>\n";
echo "<td><div align=\"left\">".$row['marca']."</div></td>\n";
echo "<td><div align=\"left\">".$row['modelo']."</div></td>\n";
echo "<td><div align=\"left\">".$row['numero_inventario']."</div></td>\n";
echo "<td><div align=\"left\">".$row['numero_activo']."</div></td>\n";
echo "<td><div align=\"left\">".$row['numero_serial_fabricacion']."</div></td>\n";
echo "<td><div align=\"left\">".$row['clase']."</div></td>\n";
echo "<td><div align=\"left\">".$row['descripcion_actividad']."</div></td>\n";
echo "<td><div align=\"left\">".$row['numero_ods']."</div></td>\n";
echo "<td><div align=\"left\">".$row['fecha_inicio_extrema']."</div></td>\n";
echo "<td><div align=\"left\">".$row['fecha_fin_extrema']."</div></td>\n";
echo "<td><div align=\"left\">".$row['pto_trabajo_ejecutante']."</div></td>\n";
echo "<td><div align=\"left\">".$row['status_ods']."</div></td>\n";
echo "<td><div align=\"left\">".$row['texto_reparacion']."</div></td>\n";
echo "<td><div align=\"left\">".$row['fecha_ejecucion']."</div></td>\n";
echo "<td><div align=\"left\">".$row['hora_inicio']."</div></td>\n";
echo "<td><div align=\"left\">".$row['hora_fin']."</div></td>\n";
echo "<td><div align=\"left\">".$row['id_reporte']."</div></td>\n";
echo "<td><div align=\"left\">".$row['id_producto']."</div></td>\n";
echo "<td><div align=\"left\">".$row['descripcion']."</div></td>\n";
echo "<td><div align=\"left\">".$row['cantidad_utilizada']."</div></td>\n";
echo "<td><div align=\"left\">".$row['und_medida']."</div></td>\n";
echo "<td><div align=\"left\">".$row['cod_almacen']."</div></td>\n";
echo "<td><div align=\"left\">".$row['lote']."</div></td>\n";
$i=$i+1;
} while($row = mysql_fetch_array($stmt));
echo "<td><div align=\"left\">".$valores["total"]."</div></td>\n";
echo "</tr>\n";
echo "</table>\n";
?>

el codigo crea la tabla perfectamente, lo que no se como hacer, es que en base al mismo numero de reporte me coloque los repuestos en la misma fila y no me repita todos los datos, es decir que id_producto,descripcion, cantidad_utilizada, und_medidad, cod_almacen_ y lote se repitan en la misma fila si un reporte usa 20 repuestos deberian aparecer los 20 repuestos en la misma fila y no repetirse la informacion 20 veces.