I am developing a query to be able to extract the data from a DB to a table in PHP, my problem is that it shows me the data but they jump in different lines, I want the results to be output in a single row.
The query I'm using is:
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;
}
}
And to show the data the following code
<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>
But it shows me in the following way and I want everything to be in a single row related by the start column