<?PHP
if($_SESSION['user']){
}
else{
}
$username = $_SESSION['user'];
require 'includes/config.php';
$needdate = ("needdate");
?>
<html>
<head>
<title><?=$config['title']?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<table border="2" align="center">
<tr>
<td>id</td>
<td>Имя пользователя</td>
<td>Пароль</td>
<td>Класс</td>
<td>Тип учетной записи</td>
<td><input type="date" name="needdate" value="<?php echo $_POST['needdate']?>"/></td>
<th><input type="submit" name="ondate" value="На дату" onclick="myFunction('.$row['needdate'].')" /></th>
</tr>
<?php
$where = "WHERE `user` = '$username'";
$wherecase = " AND `class` = '1'";
$result = mysqli_query($connection, "SELECT * FROM users $where $wherecase"); $sum += $row['class'];
$sum2 += $row['type'];
/* $needdate = $_POST['needdate'];
$result = mysqli_query($connection, "SELECT * FROM users $where");
print_r($result);
$where = "WHERE `user` = 'admin'";
if($_POST['needdate']){
$class= ($_POST['needdate']) // в этой строчке фильтруем полученые через GET данные
$cup = $where . "AND `needdate` = $cratedate";//если есть фильрация по полю class запрос станет таким "SELECT * FROM users WHERE `user` = 'admin' AND `class` = 1 "
}
// делаете что угодно
while ($row = mysqli_fetch_array($result)):
$sum += $row['class'];
$sum2 += $row['type']; */
Print '<tr>';
Print '<td align="center">'. $row['id'] . "</td>";
Print '<td align="center">'. $row['user'] . "</td>";
Print '<td align="center">'. $row['password'] . "</td>";
Print '<td align="center">'. $row['class'] . "</td>";
Print '<td align="center">'. $row['type'] . "</td>";
Print '<td align="center">'. $row['cratedate'] . "</td>";
Print '<td align="center"><a href="edit.php?id='. $row['id'] .'">edit</a> </td>';
Print '<td align="center"><a href="#" onclick="myFunction('.$row['id'].')">delete</a> </td>';
Print '</tr>';
endwhile;?>
<form method="POST" action="/add.php">
<tr>
<th>#</th>
<th><input type="text" name="user" value="<?=$user?>"/><br/></th>
<th><input type="text" name="password" value="<?=$password?>"/><br/></th>
<th><input type="number" name="class" step="1" value="<?=$class?>"/><br/></th>
<th><input type="number" name="type" step="1" value="<?=$type?>"/><br/></th>
<th><input type="date" name="cratedate" value="<?php echo($result2);?>"/><br/></th>
<th><input type="submit" name="add" value="Добавить"/></th>
</tr>
</form>
<tr>
<td><?=$row['id']?></td>
<td><?=$row['user']?></td>
<td>Cуммма:</td>
<td><?=$sum?></td>
<td><?=$sum2?></td>
<td></td>
</tr>
</table>
<script>
function myFunction(id)
{
var r=confirm("Удалить?");
if (r==true)
{
window.location.assign("delete.php?id=" + id);
}
}
function myFunction(needdate)
{
var r=confirm("отсортировать на дату <?echo $_POST['needdate']?>?");
if (r==true)
{
window.location.assign("delete.php?id=" + id); // не придумал что писать
}
}
</script>
</body>
</html>