/* pocko: (cas, mesto, teplota, oblacnost, pocasie, rychlostvetra, smervetra) */ $sql = "SELECT * FROM texty ORDER BY id DESC;"; $stmt = $con->prepare($sql); $q = $stmt->execute(); $vsetky = $stmt->fetchAll(PDO::FETCH_ASSOC); $ar = []; // empty array foreach ($vsetky as $data) { $ar[$data['id']] = $data['obsah']; } $mysqldate = date("Y-m-d H:00:00\n", strtotime('-10 hours')); $sql = "SELECT * FROM pocko WHERE cas > :cas ORDER BY cas DESC;"; $stmt = $con->prepare($sql); $q = $stmt->execute([':cas' => $mysqldate]); $dalsie = $stmt; echo print_record_header(date("d.m.Y")); foreach ($dalsie as $data) { $year = date('Y', strtotime($data['cas'])); $month = date('n', strtotime($data['cas'])); $day = date('j', strtotime($data['cas'])); $triplet = array('y' => $year, 'm' => $month, 'd' => $day); echo print_record_html($data, $ar); } ?> </table> </body> </html>
function print_den_begin($triplet, &$p) { $hide = 1; $hidestyle = ''; $name = '' . $triplet['y'] . '-' . $triplet['m'] . '-' . $triplet['d']; $pd = $p[$triplet['y']][$triplet['m']][$triplet['d']]; $priemer = round($pd['sucet'] / $pd['pocet'], 1); if ($p['current']['y'] == $triplet['y'] && $p['current']['m'] == $triplet['m'] && $p['current']['d'] == $triplet['d']) { $hide = 0; } if ($hide == 1) { $hidestyle = 'display: none;'; } return "<tr><td>Deň " . $triplet['d'] . "</td>" . tri_teploty($priemer, $pd['max'], $pd['min'], $name, $hide) . "</tr><tr id=\"t-" . $name . "\" style=\"" . $hidestyle . "\"><td class=\"td-preden\" colspan=\"5\"><table class=\"den\">" . print_record_header(); }