query('SELECT id, texte, points, team, id_staff FROM scores');
if(isset($_GET['del']) AND !empty($_GET['del']))
{
$del = (int) htmlspecialchars($_GET['del']);
$req_del = $db->prepare("SELECT id_staff FROM scores WHERE id = ?");
$req_del->execute(array($del));
$staff = $req_del -> fetchAll(PDO::FETCH_ASSOC);
if($user['perm'] >= 3 OR $staff[0]['id_staff'] == $_SESSION['id']) {
$req_del = $db->prepare('DELETE FROM scores WHERE id =?');
$req_del->execute(array($del));
header('Location: stats.php');
}
}
if(isset($_POST['teamall'])) {
$req = $db->query('SELECT id, texte, points, team, id_staff FROM scores');
}
if(isset($_POST['team0'])) {
$req = $db->query('SELECT id, texte, points, team, id_staff FROM scores WHERE team = 0');
}
if(isset($_POST['team1'])) {
$req = $db->query('SELECT id, texte, points, team, id_staff FROM scores WHERE team = 1');
}
if(isset($_POST['send'])) {
if(isset($_POST['texte']) AND !empty($_POST['texte']) AND isset($_POST['point']) AND !empty($_POST['point']) AND isset($_POST['team']) AND !empty($_POST['team'])) {
$texte = htmlspecialchars($_POST['texte']);
$point = (int) htmlspecialchars($_POST['point']);
$team = htmlspecialchars($_POST['team']);
switch ($team) {
case "t0":
$team_int = 0;
break;
case "t1":
$team_int = 1;
break;
}
if(strlen($pseudo) <= 50) {
$req_ins = $db->prepare("INSERT INTO scores(texte, points, team, id_staff) VALUES(?, ?, ?, ?)");
$req_ins->execute(array($texte, $point, $team_int, $_SESSION['id']));
header('refresh:0');
} else {
$error = "le texte de doit pas dépasser 50 char";
}
} else {
$error = "Tout les champs doivent être complétés";
}
}
?>
Admin / Stats
".$error."";
}
?>
ID (db)
| Texte
| Points
| Team
| Staff
| Action
|
fetch()) {
?>
= $stat['id'] ?> |
= $stat['texte'] ?> |
= $stat['points'] ?> |
|
prepare("SELECT pseudo FROM admin WHERE id = ?");
$req_adm->execute(array($stat['id_staff']));
$staff = $req_adm -> fetchAll(PDO::FETCH_ASSOC);
if(isset($staff[0]['pseudo'])) {
echo $staff[0]['pseudo']." (".$stat['id_staff'].")";
} else {
echo "UNDEFINED "."(".$stat['id_staff'].")";
}
?> |
prepare("SELECT id_staff FROM scores WHERE id = ?");
$req_int->execute(array($stat['id']));
$staff = $req_int -> fetchAll(PDO::FETCH_ASSOC);
if($user['perm'] >= 3 OR $staff[0]['id_staff'] == $_SESSION['id']) {
?>X |