Site/getData2.php

59 lines
2.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
header('Content-Type: text/html; charset=UTF-8');
$conn = mysqli_connect("localhost", "root", "506763", "workout");
if (!$conn) {
die("Ошибка: " . mysqli_connect_error());
}
// $start_date = $_POST["sd"];
// $end_date = $_POST["ed"];
$nick = $_POST["user"];
$sql = "SELECT * FROM workout.v_workout_tasks_w2 WHERE user = '" . $nick . "' ORDER BY task_id;";
$day_count = 0;
$row_count = 0;
$last_day = '';
if($result = mysqli_query($conn, $sql)){
foreach($result as $row){
if ($day_count == 0) {
echo "<tr>";
echo '<td class="table-head-top" colspan="5"><b>' . $row["week"] . '</b></td>';
echo "</tr>";
echo "<tr>";
echo '<td class="table-head" colspan="5"><b class="day-name">[' . $row["date"] . '] ' . $row["day_name"] . '</b></td>';
echo "</tr>";
echo '<tr class="odd">';
echo '<td class="exercise-head" id="exercise-head"><strong>Упражнение</strong></td>';
echo '<td class="muscle-group-head" id="muscle-group-head"><strong>Группа мышц</strong></td>';
echo '<td class="count-head" id="count-head"><strong>Время/подходы</strong></td>';
echo '<td class="leha" id="leha"><strong>Вес</strong></td>';
$last_day = $row["day_name"];
$day_count = 1;
}
if ($row["day_name"] != $last_day) {
$last_day = $row["day_name"];
echo "<tr>";
echo '<td class="table-head" colspan="5"><b class="day-name">[' . $row["date"] . '] ' . $row["day_name"] . '</b></td>';
echo "</tr>";
$row_count = 0;
}
$tr = '';
if ($row_count % 2 != 0) {
$tr = '<tr class="odd">';
} else {
$tr = '<tr>';
}
echo $tr;
echo '<td class="exercise">'. $row["exercise"] .'</td>';
echo '<td class="muscle-group">' . $row["muscle_group_name"] . '</td>';
echo '<td class="count">' . $row["sets_count"] . '</td>';
echo '<td class="l-prim">' . $row["weigth"] . '</td>';
echo '</tr>';
$row_count = $row_count + 1;
}
//echo "<tr class='table-row'><td class='table-cell' colspan=3 style='text-align: right;'>Итого:</td><td class='table-cell'>" . mysqli_num_rows($result) . "</td></tr>";
mysqli_free_result($result);
} else{
echo "Ошибка: " . mysqli_error($conn);
}
mysqli_close($conn);
?>