Good day, I ask for help, the situation is this: there is a table in MySql:
task: bring it to the page in the form:
I created the table header as follows:
<thead> <tr> <th> </th> <?php if ($mysqli->connect_errno) { printf("Соединение не удалось: %s\n", $mysqli->connect_error); exit(); } $sqltableclandate = "SELECT * FROM `nametable` GROUP BY Date"; $sqltableclanResultdate = $mysqli->query($sqltableclandate); while($tableclandate = $sqltableclanResultdate->fetch_assoc()) {?> <th><?php echo $tableclandate['Date'];?></th> <? }?> </tr> </thead>
But further plugging ....
Tell me where to dig and where to look)
I forgot to add yesterday: Addendum: if there is no information for a certain date, then the cell should be 0 or N / A
Adding all table code at the moment:
<?php require_once("includes/connection_new.php"); ?> <div class="content"> <div id="TableClan"> <h2>Статистика:</h2> <table class="tablesorter" id="myTable"> <thead> <tr> <th>Дата</th> <?php $query_dateclan = "SELECT * FROM `DBname`.`stats` GROUP BY Date"; if($resultclandate = $mysqli->query($query_dateclan)){ $rowclandate=$resultclandate->fetch_assoc(); $kol_rowsclandate = $resultclandate->num_rows; for($i=0; $i<$kol_rowsclandate; $i++){?> <th> <? echo $rowclandate['Date']; ?> </th> <? }}?> </tr> </thead> <tbody> <tr> <td><? echo $rowclandate['name'] ?></td> </tr> </tbody> </table> </div> <!-- тело любых страниц.php --> </div>
base view: table: stat (as you can see name5 appeared later)