lundi 26 mars 2018

Different data per column using Jquery and PHP

I'd like to populate a table with the first column from a DB, and the second column with some operated values to have the percentaje (calculated from another query from DB). Is it posible using just that?.

Here are the queries

$query = "SELECT DatosSpend.ind, DatosSpend.area, ROUND(SUM(usdAmount),0) AS total, (select ROUND(SUM(usdAmount),0) AS abas FROM DatosSpend HAVING area='Abastos') as abas FROM DatosSpend GROUP BY ind";

$queryAbas = "SELECT DatosSpend.usdAmount, DatosSpend.ind, DatosSpend.area, SUM(usdAmount) AS abas FROM DatosSpend WHERE area like 'Abastos' GROUP BY ind";

With this result:

$result = mysqli_query($connect, $query);

And this is how im trying to populate the data with php:

<tbody>
    <?php
      while($row = mysqli_fetch_array($result)){
        echo '
        <tr>
          <td class="text-center title-row-table">'.$row["ind"].'</td>
          <td class="text-right table-spend">$'.$row["total"].'</td>
          <td class="text-right table-spend">'.$row["abas"].'%</td>
        </tr>
        ';
      }
    ?>
  </tbody>




Aucun commentaire:

Enregistrer un commentaire