<?php
$mysqli = new mysqli('connect');
$result = $mysqli->query("SELECT * FROM people");
?>
<?php
if(isset($_SESSION['sMsg'])): ?>
<div class="alert alert-<?=$_SESSION['sMsgType']?>">
<?php
echo $_SESSION['sMsg'];
unset($_SESSION['sMsg']);
?>
</div>
<?php endif ?>
<?php
require_once 'manageusers.php';
print_r($id);
?>
<div class="text-secondary" style="font-size: 40px">Участники</div>
<form action="/manageusers.php" method="POST">
<div class="input-group input-group-sm">
<input class="form-control maxLengthInputNumber" value="<?php echo $id?>" type="text" name="id" placeholder="№" required>
<input class="form-control maxLengthInputNumber" value="<?php echo $id_start?>" type="text" name="id_start" placeholder="№ старта">
<input class="form-control maxLengthInputNumber" value="<?php echo $name?>"type="text" name="name" placeholder="ФИО" required>
<input class="form-control maxLengthInputNumber" value="<?php echo $birth?>" type="text" name="birth" placeholder="Год рождения">
<input class="form-control maxLengthInputNumber" value="<?php echo $ranked?>" type="text" name="ranked" placeholder="Разряд">
<input class="form-control maxLengthInputNumber" value="<?php echo $region?>"type="text" name="region" placeholder="Регион">
<div class="d-grid col-2 mx-auto">
<button class="btn btn-primary" name="addUser">ОК</button>
</div>
</div>
</form>
<BR>
<BR>
<div class="row justify-content-center">
<table class="table">
<thead>
<tr>
<th>№</th>
<th>№ старта</th>
<th>ФИО</th>
<th>Дата рождения</th>
<th>Звание</th>
<th>Регион</th>
</tr>
</thead>
<?php
while ($users = $result->fetch_assoc()) :?>
<tr>
<td><?php echo $users['id'];?></td>
<td><?php echo $users['id_start'];?></td>
<td><?php echo $users['name'];?></td>
<td><?php echo $users['birth'];?></td>
<td><?php echo $users['ranked'];?></td>
<td><?php echo $users['region'];?></td>
<td>
<a href="/manageusers.php?editmember=<?php echo $users['DB_ID']?>"><button class="btn btn-warning">Редактировать</button></a>
<a href="/manageusers.php?deleteUser=<?php echo $users['DB_ID']?>"><button class="btn btn-danger">Удалить</button></a>
</td>
</tr>
<?php endwhile;
$result->data_seek(0);
?>
</table>
</div>
<?php
session_start();
$connection = new PDO("connect");
$id = '';
$id_start = '';
$name = '';
$birth = '';
$ranked = '';
$region = '';
if(isset($_POST['addUser'])){
$addUser = [
'i' => $_POST['id'],
'is' => $_POST['id_start'],
'na' => $_POST['name'],
'bi' => $_POST['birth'],
'ra' => $_POST['ranked'],
're' => $_POST['region'],
];
$sql = "INSERT INTO people (id, id_start, name, birth, ranked, region) VALUES(:i,:is,:na,:bi,:ra,:re)";
$query = $connection->prepare($sql);
$query -> execute($addUser);
$_SESSION['sMsg'] = "Участник добавлен!";
$_SESSION['sMsgType'] = "success";
header("location: /fishing");
}
if(isset($_GET['deleteUser'])){
$deleteUser = [
'id' => $_GET['deleteUser'],
];
$sql = "DELETE FROM people WHERE DB_ID=:id";
$query = $connection->prepare($sql);
$query -> execute($deleteUser);
$_SESSION['sMsg'] = "Участник удален!";
$_SESSION['sMsgType'] = "danger";
header("location: /fishing");
}
if(isset($_GET['editmember'])){
$editMember = [
'id' => $_GET['editmember'],
];
$sql = "SELECT * FROM people WHERE DB_ID=:id";
$query = $connection->prepare($sql);
$query -> execute($editMember);
$result = $query -> fetch(PDO::FETCH_GROUP|PDO::FETCH_ASSOC);
$id = $result['id'];
$id_start = $result['id_start'];
$name = $result['name'];
$birth = $result['birth'];
$ranked = $result['ranked'];
$region = $result['region'];
}
?>
Второй день бьюсь, этот код должен при нажатии на редактировать, тащить из базы данные и вставлять в input. хоть я и подключил
require_once
переменные все равно не подтягиваются.. помогите, что не так делаю... ?