I have this MySQL
table MONTHNAME
generated by querying from the database using the following script using PHP
.
$query = 'SELECT monthname(`dateAdded`) as MONTHNAME,sum(`shift1PinCount`+`shift2PinCount`) from `supervisorupdate` WHERE YEAR(`dateAdded`) = YEAR(CURDATE()) group by monthname(`dateAdded`) ORDER BY monthname(`dateAdded`) DESC';
$queryExecute = mysqli_query($conn, $query);
I want to show this table as it is into my HTML
page using PHP
. As from I know normally we use
while($row = mysqli_fetch_array($queryExecute)){
echo $row['someColumnName'];
}
In this case, I can’t do that since I am doing some calculations and getting output as a table. Can someone guide me on how to show this table?
Edit 1
Here is a picture of the result that I am getting using phpMyadmin
. So the HTML table should be similar to this
So for HTML
side, it should show something like this
<table class="table">
<thead>
<tr>
<th scope="col" id="month">Month</th>
<th scope="col" id="sum">Sum</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" id="jan">January</th>
<td id="janPinCount">3456</td>
</tr>
<tr>
<th scope="row" id="feb">February</th>
<td id="febPinCount">443</td>
</tr>
</tbody>
</table>
2
Answers
you can do this. put this after the table body
Try this one, I added an alias on your sum(
shift1PinCount
+shift2PinCount
) column as PinCount.