Hej mam taką strone:
Która ciągnie dane z bazy:
Takim o to kodem: historia_userow.php
<!DOCTYPE HTML>
<html lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Panel admina</title>
</head>
<body>
<h1>Panel Historii Użytkowników</h1>
<table summary= TEST, id=tabela>
<p><a href="index1.php" >Wróć do historii usuwania</a></p>
<tr>
<th>Id</th><th>Użytkownik</th><th>ID użytkownika</th><th>Historia logowania</th>
</tr>
<?php
include ('polacz.php');
$l = 1;
if ($sql = $mysqli->prepare("SELECT * FROM logowanie"))
{
$sql->execute();
$sql->bind_result($id, $user, $pass, $email);
while ($sql->fetch() || $l<=1)
{
echo "<tr>
<td>$l</td>
<td>$user</td>
<td>$id</td>
<td><a href=\"historia_userow2.php?id=$id\">Pokaż historie</a></td>
</tr>";
$l++;
}
$sql->close();
}
else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
$mysqli->close();
?>
</table>
</body>
</html>
Klikając pokaż historie ma mi pokazać coś takiego:
Z bazy:
O takim kodzie: historia_userow.php
<!DOCTYPE HTML>
<html lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Panel admina</title>
</head>
<body>
<h1>Historia logowań</h1>
<table summary= TEST, id=tabela>
<p><a href="historia_userow.php" >Wróć do panelu historii użytkownika</a></p>
<tr>
<th>Id</th><th>Data i czas logowania</th>
</tr>
<?php
include('polacz.php');
$l = 1;
if ($sql = $mysqli->prepare("SELECT * FROM historia WHERE action_type = 2"))
{
$sql->execute();
$sql->bind_result($id, $user_id, $action_type, $created_at);
while ($sql->fetch() || $l<=1)
{
echo "<tr>
<td>$l</td>
<td>$created_at</td>
</tr>";
$l++;
}
$sql->close();
}
?>
</table>
<h1>Historia wylogowań</h1>
<table summary= TEST, id=tabela>
<tr>
<th>Id</th><th>Data i czas logowania</th>
</tr>
<?php
$l = 1;
if ($sql = $mysqli->prepare("SELECT * FROM historia WHERE action_type = 1"))
{
$sql->execute();
$sql->bind_result($id, $user_id, $action_type, $created_at);
while ($sql->fetch() || $l<=1)
{
echo "<tr>
<td>$l</td>
<td>$created_at</td>
</tr>";
$l++;
}
$sql->close();
}
?>
</table>
</body>
</html>
I teraz do senda. Jak zauważyliście ciągnie mi z bazy dla każdego użytkownika tą samą historie logowań co wylogowań, i mam problem bo user_id z bazy historia jest inny ale nie umiem go tu wprowadzić aby dla każdego usera wprowadzał jego historie, po prostu utknąłem. proszę o pomoc.