PHP - Creacion de tablas desde Base de Datos MYSQL

 
Vista:

Creacion de tablas desde Base de Datos MYSQL

Publicado por VICTOR (2 intervenciones) el 08/08/2018 15:23:05
Buenos días
estoy desarrollando una consulta para poder extraer los datos de una BD a una tabla en PHP, mi pñroblema es que me muestra los datos pero se saltan en diferentes lineas, yo deseo que salga los resultados en una sola fila.

La consulta que estoy usando es:

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
class Buscadordeta
{
	private $busqueda=array();
 
	public function buscardeta()
	{
		//print_r($_GET);exit;
		$query = "SELECT D.codcon, A.MESINI,B.MESFIN, D.abrcon, C.des_corta, A.importe FROM plutimcp A
		inner join plmovmae B 
			on A.libele=B.libele and A.mesini=B.mesini
		inner join pltabmcp C
			on A.codcon=C.concepto
		inner join pltabcon D
			on C.codcon=D.codcon
		WHERE A.tipo BETWEEN 1 and 4 and B.nombre like '%".$_GET['s']."%'
		group by A.mesini, D.codcon	
		order by A.MESINI;";
		/*$res = mysql_query($query,Conectar::con() or die("Error en: $busqueda: " . mysql_error()));*/
		$res = mysql_query($query,Conectar::con()) or die("Error en: $query: " . mysql_error());
		while ($reg=mysql_fetch_assoc($res))
		{
			$this->busqueda[] = $reg;
		}
			return $this->busqueda;
	}
 
}

Y para mostrar los datos el siguiente codigo

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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<table border="2">
<tr>
		<th width="50px">INICIO</th>
		<th width="50px">REM.BAS 1001</th>
        <th width="50px">R.REUNIF 1002</th>
        <th width="50px">BON.PER 1003</th>
        <th width="50px">BON.FAMI 1004</th>
		<th width="50px">TRA.HOMO 1005</th>
        <th width="50px">COST.VID 1006</th>
        <th width="50px">MOV.REF 1007</th>
        <th width="50px">BE051.91 1008</th>
        <th width="50px">10.23%+3 1009</th>
        <th width="50px">REM ANTE 1010 </th>
        <th width="50px">ICAJ3.3% 1011 </th>
        <th width="50px">A.J.SUP 1012</th>
        <th width="50px">DS040.92 1014</th>
        <th width="50px">DL.25671 1015</th>
        <th width="50px">DL.25697 1016</th>
        <th width="50px">BE.81.93 1017</th>
        <th width="50px">BE.19.94 1018</th>
        <th width="50px">DU.80.94 1019</th>
        <th width="50px">D.118.94 1020</th>
        <th width="50px">DU090.96 1021</th>
        <th width="50px">DU073/97 1022</th>
        <th width="50px">LEY25303 1023</th>
        <th width="50px">AS.COM.T 1024</th>
        <th width="50px">ART.18 1025</th>
        <th width="50px">PEN.PROV 1026</th>
        <th width="50px">PEN.DOC 1027</th>
        <th width="50px">PEN.GRA 1028</th>
        <th width="50px">FUN.SAL 1029</th>
        <th width="50px">DL.817 1030</th>
        <th width="50px">DU011/99 1031</th>
        <th width="50px">DU037.94 1038</th>
        <th width="50px">AGUINALD 1054</th>
        <th width="50px">REINTEGR 1160</th>
        <th width="200px">TOTAL</th>
	</tr>
<?php
//COMPROBAMOS SI HAY REGISTROS EN LA BUSQUEDA, SI NO LOS HAY, MOSATRAMOS UN MENSAJE DICIENDO QUE NO HAY RESULTADOS, EN OTRO CASO, MOSTRAMOS LOS RESULTADOS
if(count($buscamedeta)==0)
{
echo "<h2>No hay resultados para su búsqueda...</h2>";
}else{
for($i=0;$i<sizeof($buscamedeta);$i++)
{
?>
	<tr>
		<td align="center">
        	<?php echo $buscamedeta[$i]["MESINI"] ."/". $buscamedeta[$i]["MESFIN"]?>
		</td>
		<td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1001")
			{
			echo $buscamedeta[$i]["importe"];
			}
 
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1002")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
		<td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1003")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1004")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1005")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1006")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1007")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1008")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1009")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1010")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1011")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1012")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
          <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1014")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1015")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1016")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1017")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1018")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1019")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1020")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1021")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1022")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
       <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1023")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1024")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1025")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1026")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1027")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1028")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1029")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1030")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1031")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1038")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1054")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
        <td align="center">
			<?php
			if ($buscamedeta[$i]["codcon"]=="1160")
			{
			echo $buscamedeta[$i]["importe"];
			}
			?>
		</td>
	</tr>
 
<?php
}
}
?>
 
 
</table>

Pero me muestra de la siguiente manera y deseo que todo sea en una sola fila relacionado por la columna inicio

resultado
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
sin imagen de perfil
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Creacion de tablas desde Base de Datos MYSQL

Publicado por zendi (1056 intervenciones) el 08/08/2018 15:55:07
Primero Ordena mejor el codigo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar