PHP - COMBINAR CELDAS CON VALOR IGUAL

 
Vista:
Imágen de perfil de Eduardo
Val: 165
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

COMBINAR CELDAS CON VALOR IGUAL

Publicado por Eduardo (174 intervenciones) el 19/07/2021 18:36:50
hola a todos espero me puedan ayudar.. en este caso quisiera que esta tabla que me muestra valores de una base de datos según consulta de fecha me agrupe las placas cuando estas sean de valor igual por ejemplo:

Captura

Que las muestre así:

Captura2

acá pongo el código que uso el cual em lista todo y me gustaría que agrupara o combinara en la parte de donde muestra los resultados de ".$row["placa"]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php include("seguridad.php");?>
<?
header("Content-Type: text/html;charset=utf-8");
//$codigo = $_GET['codigo'];
$placa=$_GET['placa'];
$fecha1w=$_GET['fecha1'];
$fecha2w=$_GET['fecha2'];
$ordenw=$_GET['orden'];
if($fecha1w>$fecha2w){
echo '<script type="text/javascript">alert("La fecha inicial no puede ser mayor a la fecha final");window.window.history.go(-1);</script>';
exit();
}
//$fecha22w = date("d/m/Y", strtotime($fecha1w));
$fecha22w = date("Y-m-d", strtotime($fecha1w));
$fecha33w = date("Y-m-d", strtotime($fecha2w));
//--------------------------------------------------------
$fecha2=substr($fecha, 0, 10);
if(($placa=="TODOSSERV")||($placa=="TODOSPLAC")||($placa=="TODOS")){
$plac="";
$me="INGRESOS Y SALIDAS";
}else if($placa=="INGRESOS"){
$plac="";
$me="SOLO INGRESOS";
}else{
$plac= "del vehículo seleccionado " .$placa;
$me="VEHICULO PLACA: ".$placa;
}
?>
<?php
function fechaCastellano ($fecha) {
  $fecha = substr($fecha, 0, 10);
  $numeroDia = date('d', strtotime($fecha));
  $dia = date('l', strtotime($fecha));
  $mes = date('F', strtotime($fecha));
  $anio = date('Y', strtotime($fecha));
  $dias_ES = array("LUNES", "MARTES", "MIERCOLES", "JUEVES", "VIERNES", "SABADO", "DOMINGO");
  $dias_EN = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
  $nombredia = str_replace($dias_EN, $dias_ES, $dia);
$meses_ES = array("ENERO", "FEBRERO", "MARZO", "ABRIL", "MAYO", "JUNIO", "JULIO", "AGOSTO", "SEPTIEMBRE", "OCTUBRE", "NOVIEMBRE", "DICIEMBRE");
  $meses_EN = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  $nombreMes = str_replace($meses_EN, $meses_ES, $mes);
  return $nombredia." ".$numeroDia." DE ".$nombreMes." DE ".$anio;
 //return $numeroDia." de ".$nombreMes." de ".$anio;
}
$Newfecha1=fechaCastellano($fecha1w);
$Newfecha2=fechaCastellano($fecha2w);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//ES" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Listado</title>
 <link type="text/css" href="css/style.css" rel="stylesheet" />
        <!--    ESTILO GENERAL 2   -->
        <!--    JQUERY   -->
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" language="javascript" src="js/funciones.js"></script>
        <!--    JQUERY    -->
        <!--    FORMATO DE TABLAS 2    -->
        <link type="text/css" href="css/demo_table.css" rel="stylesheet" />
        <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<!------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------>
<style type="text/css">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #333;
}
<!---------------------------------------
</style>
<link href="estilos.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv1 {
	position: absolute;
	left: 134px;
	top: 9px;
	width: 848px;
	height: 87px;
	z-index: 1;
}
#apDiv2 {
	position: absolute;
	left: 169px;
	top: 266px;
	width: 190px;
	height: 112px;
	z-index: 1;
}
.df {	font-family: Arial, Helvetica, sans-serif;
}
.df1 {font-family: Arial, Helvetica, sans-serif;
}
.oculto-impresion {    display: none !important;
}
.s {text-align: center;
	font-weight: bold;
	color: #000;
}
.titulito {	font-size: 9px;
}
#algo {display:none}
#algo {display:block}
.ty {
	text-align: right;
}
.yu {
	text-align: left;
}
.il {
	text-align: center;
}
.il td {
	color: #000;
}
.ji {
	color: #000;
}
.kl {
	color: #000;
}
.jl {
	color: #000;
}
.il td {
	font-size: 11px;
}
#apDiv3 {
	position: absolute;
	left: 943px;
	top: 124px;
	width: 42px;
	height: 30px;
	z-index: 1;
}
.hyu {
	text-align: center;
}
.il td .kl strong {
	font-size: 12px;
}
</style>
<style>
	@media print {
	.impre {display:none}
		font-size:7pt;font-family: Arial, Helvetica, sans-serif;}
	    body{
    margin-left: 2em;
    margin-right: 2em;
margin-top:2.em; margin-bottom:2.em;     font-size: 12px;
}
	    margin-left:2em; margin-right:2em; margin-top:2.em; margin-bottom:2.em;
	}
</style>
<style>
.tableTT {
	border-collapse: collapse;
	width: 100%;
	margin-top:10px;
    td border: 1px solid #ccc;
	padding: 10px;
}
	#grilla tr:hover{
}
	#grilla2 tr:hover{
    background: lightcyan;
		cursor: default;
}
	#grilla3 tr:hover{
    background: lightcyan;
		cursor: default;
}
	#grilla4 tr:hover{
    background: lightcyan;
		cursor: default;
}
	#grilla5 tr:hover{
    background: lightcyan;
		cursor: default;
}
</style>
</head>
<body>
<table width="70%" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr>
      <td width="1018" height="15" colspan="4" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
        <tr>
          <td><center>
            <h2>
              INFORME VIAJES <br />FECHA:
              <?php echo $Newfecha1 ?> AL <?php echo $Newfecha2 ?><span style="font-size: 12px"></span><br /><?php echo $me ?>
          </h2></center></td>
        </tr>
        <tr>
          <td height="47"><table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
            <tr>
              <td width="979" height="22"><table width="100%" border="1" align="center" cellpadding=1 cellspacing=0 class="tableTT" id="grilla2" style="font-size: 8pt">
                <tr class="il">
                  <td width="37" height="21" bgcolor="#FF6600"><font face="verdana"><b>VIAJE</b></font></td>
                  <td width="170" bgcolor="#FF6600"><font face="verdana"><b>PLACA</b></font></td>
                  <td width="60" bgcolor="#FBFF78"><font face="verdana"><b>HORA ENTRADA</b></font></td>
                  <td width="87" bgcolor="#FF6600"><font face="verdana"><b>PESO ENTRADA</b></font></td>
                  <td width="68" bgcolor="#FBFF78"><font face="verdana"><b>HORA SALIDA</b></font></td>
                  <td width="81" bgcolor="#FF6600"><font face="verdana"><b>PESO SALIDA</b></font></td>
                  <td width="52" bgcolor="#FF6600"><font face="verdana"><b>NETO</b></font></td>
                  <td width="130" bgcolor="#FF6600"><font face="verdana"><b>MUNICIPIO</b></font></td>
                  <td width="128" bgcolor="#FF6600"><font face="verdana"><b>CONDUCTOR</b></font></td>
                  <td width="133" bgcolor="#FF6600"><font face="verdana"><b>EMPRESA</b></font></td>
                  </tr>
                <?php
  $link = @mysql_connect("localhost", "usuario","contrasena") or die ("Error al conectar a la base de datos.");
  @mysql_select_db("basededatos") or die ("Error al conectar a la base de datos.");
//---------------------------------------------------------------------
if($placa=="TODOS"){
 // $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='Listo' ORDER BY id $ordenw";
  $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='Listo' ORDER BY horaentrada ASC";
}else if($placa=="TODOSPLAC"){
 // $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='Listo' ORDER BY id $ordenw";
  $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='Listo' ORDER BY placa ASC";
//----------------------------------------------------
}else if($placa=="TODOSSERV"){
 // $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='Listo' ORDER BY id $ordenw";
  $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND empresa='SERVIASEO' AND otro='Listo' ORDER BY placa ASC";
}else if($placa=="INGRESOS"){
 // $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='Listo' ORDER BY id $ordenw";
  $query = "SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND otro='' ORDER BY placa ASC";
}else{
 //$query ="SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND placa='".$placa."' AND otro='Listo' ORDER BY id $ordenw";
 $query ="SELECT * FROM basculas WHERE fecha BETWEEN '$fecha22w' AND '$fecha33w' AND placa='".$placa."' AND otro='Listo' ORDER BY id ASC";
}
  //$query = "SELECT novedades.*, conductor.* FROM novedades, conductor WHERE fecha_novedad BETWEEN '$fecha22w' AND '$fecha33w' ORDER BY fecha_novedad $ordenw";
  $result = mysql_query($query);
  $numero = 0;
  $is=1;
  while($row = mysql_fetch_array($result))
  {
    echo "<tr><td width=\"70\"><center><font face=\"verdana\">" .
	    $is++ . "</font></center></td>";
//substr('abcdef', 0, 4);  // abcd
//bgcolor="#B5EBFF"
    echo "<td width=\"113\"><center><font face=\"verdana\">".$row["placa"] . "</font></center></td>";
	echo "<td bgcolor=\"#FDFFCC\" width=\"113\"><center><font face=\"verdana\">".substr($row["horaentrada"], 0, 8). "</font></center></td>";
	echo "<td width=\"113\"><center><font face=\"verdana\">".$row["pesoentrada"]. "</font></center></td>";
    echo "<td bgcolor=\"#FDFFCC\" width=\"113\"><center><font face=\"verdana\">".substr($row["horasalida"], 0, 8). "</font></center></td>";
	echo "<td width=\"113\"><center><font face=\"verdana\">".$row["pesosalida"]. "</font></td>";
	echo "<td bgcolor=\"#B5EBFF\" width=\"113\"><center><font face=\"verdana\">" .$row["neto"]."</font></td>";
//trim($myString, ',');
	echo "<td width=\"353\"><font face=\"verdana\">".strtoupper(trim($row["municipio"], ' ,'))."</font></td>";
	echo "<td width=\"353\"><font face=\"verdana\">".strtoupper($row["conductor"]). "</font></td>";
	echo "<td width=\"353\"><font face=\"verdana\">".strtoupper ($row["empresa"]) . "</font>";
if(($row["empresa"]=="SERVIASEO")||($row["empresa"]=="")){
echo "";
if ($me=="SOLO INGRESOS"){
echo "&nbsp;&nbsp;<a href='agregarsalida.php?idbasculas=".$row['id']."&placa=".$row['placa']."&target='_blank'><img src='iconoeditar.png' width='16' height='16' title='Agregar Salida' /></a>";
}else{
echo "";
}
}else if(($row["empresa"]!=="EMPRESA")&&($row["otro"]=="")){
echo "";
if ($me=="SOLO INGRESOS"){
echo "&nbsp;&nbsp;<a href='agregarsalida.php?idbasculas=".$row['id']."&placa=".$row['placa']."&target='_blank'><img src='iconoeditar.png' width='16' height='16' title='Agregar Salida' /></a>";
}else{
echo "";
}
}else{
echo "&nbsp;&nbsp;<a href='reciborelleno.php?idrecibo=".$row['id']."&placa=".$row['placa']."&target='_blank'><img src='iconofactura.png' width='8' height='8' title='Imprimir Recibo' /></a>";
if ($me=="SOLO INGRESOS"){
echo "&nbsp;&nbsp;<a href='agregarsalida.php?idbasculas=".$row['id']."&placa=".$row['placa']."&target='_blank'><img src='iconoeditar.png' width='16' height='16' title='Agregar Salida' /></a>";
}else{
echo "";
}
}"</td>";
    $numero++;
  }
  echo "<tr><td colspan=\"15\"><p align=right><font face=\"verdana\"><b>TOTAL VIAJES: " . $numero . "&nbsp;</b></font></p></td></tr>";
  mysql_free_result($result);
  mysql_close($link);
?>
  <?php
if($numero=="0"){
echo '<script type="text/javascript">alert("No Hay Registros para este dia '.$dia1.' '.ucfirst($mesw1).' '.$ano1.' '.$plac.'");</script>';
}
?>
                </table></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
    </tr>
  </table>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder