mirror of
https://github.com/FlyInTheBox/31TSAI.git
synced 2024-12-22 14:26:59 +01:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
f1b201c121
17 changed files with 354 additions and 0 deletions
8
twsia01-master/include/db_conn.php
Normal file
8
twsia01-master/include/db_conn.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
$servername = "127.0.0.1";
|
||||
$username = "oziminai";
|
||||
$password = "password";
|
||||
$database = "oziminai";
|
||||
|
||||
$conn = mysqli_connect($servername, $username, $password, $database);
|
||||
?>
|
2
twsia01-master/include/db_disconn.php
Normal file
2
twsia01-master/include/db_disconn.php
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
mysqli_close($conn);
|
50
twsia01-master/index.php
Normal file
50
twsia01-master/index.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/style/style.css">
|
||||
<link rel="stylesheet" href="/style/main.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
|
||||
<title>projekt z php</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include './include/db_conn.php'
|
||||
?>
|
||||
<div class="main">
|
||||
<div class="sidebar">
|
||||
<div class="list">
|
||||
<ul>
|
||||
<li><a href="?page=main">Strona Główna</a></li>
|
||||
<li><a href="?page=test">Test połączenia</a></li>
|
||||
<li><a href="?page=czytelnicy">Tabela Czytelnicy</a></li>
|
||||
<li><a href="?page=dzialy">Tabela Działy</a></li>
|
||||
<li><a href="?page=ksiazki">Tabela Książki</a></li>
|
||||
<li><a href="?page=pracownicy">Tabela Pracownicy</a></li>
|
||||
<li><a href="?page=stanowiska">Tabela Stanowiska</a></li>
|
||||
<li><a href="?page=wypozyczenia">Tabela Wypożyczenia</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main-content">
|
||||
<?php
|
||||
if (isset($_GET['page'])) {
|
||||
if (file_exists('PAGES/' . $_GET['page'] . '.php'))
|
||||
include('PAGES/' . $_GET['page'] . '.php');
|
||||
else
|
||||
echo '<h2>TA STRONA NIE ISTNIEJE</h2>';
|
||||
} else {
|
||||
include 'pages/main.php';
|
||||
}
|
||||
include './include/db_disconn.php'
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
3
twsia01-master/pages/czytelnicy.php
Normal file
3
twsia01-master/pages/czytelnicy.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Tabela czytelnicy</h1>
|
||||
</div>
|
20
twsia01-master/pages/dzialy.php
Normal file
20
twsia01-master/pages/dzialy.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Tabela działy</h1>
|
||||
<div class="table-wrapper">
|
||||
<?php
|
||||
$query = 'SELECT * FROM dzialy';
|
||||
$result = mysqli_query($conn, $query);
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
echo '<p>Zawiera '. mysqli_num_rows($result) .' wierszy</p>';
|
||||
echo '<table>';
|
||||
echo '<tr><th>Id_dzial</th><th>Nazwa</th><th colspan="2"><a class="add" href="?page=dzialy_dodaj"><span class="material-symbols-outlined">add</span></a></th><tr>';
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
echo '<tr><td>' . $row['Id_dzial'] . '</td><td>' . $row['Nazwa'] .'</td><td colspan="2"> <a href="?page=dzialy_edycja&id='. $row['Id_dzial'] .' &Nazwa='. $row['Nazwa'] .'"><span class="material-symbols-outlined">edit</span></a><a href="?page=dzialy_usun&id='. $row['Id_dzial'] .' &Nazwa='. $row['Nazwa'] .'"><span class="material-symbols-outlined">close</span></a></td><tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo 'brak danych';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
38
twsia01-master/pages/dzialy_dodaj.php
Normal file
38
twsia01-master/pages/dzialy_dodaj.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<div class="content-wrapper">
|
||||
<div class="table-wrapper">
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") // Zapisz dane z formularza do bazy [INSERT]
|
||||
{
|
||||
|
||||
$query = "INSERT INTO `dzialy` (Nazwa) VALUES ('" . $_POST['Nazwa'] . "')";
|
||||
echo $query;
|
||||
|
||||
if (mysqli_query($conn, $query)) {
|
||||
echo "New record created successfully";
|
||||
} else {
|
||||
echo "Error: " . $query . "<br>" . mysqli_error($conn);
|
||||
}
|
||||
|
||||
} else {
|
||||
?>
|
||||
<form action="?page=dzialy_dodaj" method="POST">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="id_dzial">Id_dzial</label></td>
|
||||
<td><input type="text" name="id_dzial" id="id_dzial" disabled></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="Nazwa">Nazwa</label></td>
|
||||
<td><input type="text" name="Nazwa" id="Nazwa"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align:center"><input type="Submit" value="Zapisz" style="padding: 3px 10px"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
34
twsia01-master/pages/dzialy_edycja.php
Normal file
34
twsia01-master/pages/dzialy_edycja.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<div class="content-wrapper">
|
||||
<div class="table-wrapper">
|
||||
<?php
|
||||
|
||||
$Id_dzial = $_GET['id'];
|
||||
$Nazwa = $_GET['Nazwa'];
|
||||
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") // Zapisz dane z formularza do bazy [INSERT]
|
||||
{
|
||||
|
||||
$Nazwa = $_POST['Nazwa'];
|
||||
$query = "UPDATE `dzialy` SET `Nazwa` = '" . $Nazwa . "' WHERE `dzialy`.`Id_dzial` = '$Id_dzial'";
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if ($result) {
|
||||
echo "Poprawnie zedytowano rekord";
|
||||
echo '<br><a href="?page=dzialy">Powrót</a>';
|
||||
} else {
|
||||
echo "Błąd edycji";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo '<form action="?page=dzialy_edycja&id=' . $Id_dzial . '&Nazwa=' . $Nazwa . '" method="post">
|
||||
<table>
|
||||
<tr><td><label for="Id_dzial">Id_dzial</label></td><td><input type="text" name="Id_dzial" value="' . $Id_dzial . '" disabled </td></tr>
|
||||
<tr><td><label for="Nazwa">Nazwa</label></td><td><input type="text" name="Nazwa" id="Nazwa" value="' . $Nazwa . '"></td></tr>
|
||||
<tr><td colspan="2" style="text-align: center"><button type="submit">Zmień</button></td></tr>
|
||||
</table>
|
||||
</form>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
28
twsia01-master/pages/dzialy_usun.php
Normal file
28
twsia01-master/pages/dzialy_usun.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Usuń dane w tabeli działy</h1>
|
||||
<div class="table-wrapper">
|
||||
<?php
|
||||
$Id_dzial = $_GET['id'];
|
||||
$Nazwa = $_GET['Nazwa'];
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") // Zapisz dane z formularza do bazy [INSERT]
|
||||
{
|
||||
|
||||
$query = "DELETE FROM dzialy WHERE `dzialy`.`Id_dzial` = '$Id_dzial'";
|
||||
$result = mysqli_query($conn, $query);
|
||||
if ($result) {
|
||||
echo "Poprawnie usunięto rekord";
|
||||
echo '<br><a href="?page=dzialy">Powrót</a>';
|
||||
} else {
|
||||
echo "Błąd usuwania";
|
||||
}
|
||||
} else {
|
||||
echo '<form action="?page=dzialy_usun&id='.$Id_dzial.'Nazwa="'. $Nazwa .' method="post">
|
||||
<table>
|
||||
<tr><td>Id_stanowisko</td><td><input type="text" name="id" id="id" value="'. $Id_dzial .'" disabled></td></tr>
|
||||
<tr><td>Nazwa</td><td><input type="text" name="nazwa" id="nazwa" value="'. $Nazwa .'" disabled></td></tr>
|
||||
<tr><td colspan="2" style="text-align: center"><button type="submit">Usuń</button></td></tr>
|
||||
</table>
|
||||
</form>';}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
3
twsia01-master/pages/ksiazki.php
Normal file
3
twsia01-master/pages/ksiazki.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Tabela książki</h1>
|
||||
</div>
|
5
twsia01-master/pages/main.php
Normal file
5
twsia01-master/pages/main.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<div class="content-wrapper">
|
||||
<div class="img-wrapper">
|
||||
<img src="/unicorn.png" alt="unicorn">
|
||||
</div>
|
||||
</div>
|
24
twsia01-master/pages/pracownicy.php
Normal file
24
twsia01-master/pages/pracownicy.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Tabela pracownicy</h1>
|
||||
<div class="table-wrapper">
|
||||
<?php
|
||||
$query = 'SELECT * FROM pracownicy
|
||||
INNER JOIN stanowiska ON stanowiska.Id_stanowisko = pracownicy.Id_stanowisko
|
||||
WHERE 1
|
||||
ORDER BY pracownicy.Wynagrodzenie ASC;';
|
||||
$result = mysqli_query($conn, $query);
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
echo '<p>Zawiera '. mysqli_num_rows($result) .' wierszy</p>';
|
||||
echo '<table>';
|
||||
echo '<tr><th>Id_pracownika</th><th>Nazwisko</th><th>Imie</th><th>Stanowisko</th><th>Miasto</th><th>Data_zatrudnienia</th><th>Wynagrodzenie</th><tr>';
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
echo '<tr><td>' . $row['Id_pracownika'] . '</td><td>'
|
||||
. $row['Nazwisko'] .'</td><td>'. $row['Imie'] .'</td><td>'. $row['Nazwa'] . '</td><td>'. $row['Miasto'] .'</td><td>'. $row['Data_zatrudnienia'] .'</td><td>'. $row['Wynagrodzenie'] .'</td><tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo 'brak danych';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
23
twsia01-master/pages/stanowiska.php
Normal file
23
twsia01-master/pages/stanowiska.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Tabela stanowiska</h1>
|
||||
<div class="table-wrapper">
|
||||
<?php
|
||||
$query = "SELECT * FROM stanowiska";
|
||||
$result = mysqli_query($conn, $query);
|
||||
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
echo '<p>Zawiera '. mysqli_num_rows($result) .' wierszy</p>'
|
||||
?>
|
||||
<table>
|
||||
<tr><th>Id stanowiska</th><th>Nazwa</th></tr>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
echo '<tr><td>' . $row['Id_stanowisko'] .'</td><td>' . $row['Nazwa'] .'</td></tr>';
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
11
twsia01-master/pages/test.php
Normal file
11
twsia01-master/pages/test.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
if (!$conn) {
|
||||
die("Próba połączenia z bazą danych zakończyła się niepowodzeniem. Błąd: "
|
||||
. mysqli_connect_error());
|
||||
}
|
||||
echo '<p>Połączono z bazą danych <b>' . $database . '</b> na serwerze <b>' . $servername . '</b><br>';
|
||||
echo 'Host info: ' . $conn->host_info . '<br>';
|
||||
echo 'MySQLi stat: ' . mysqli_stat($conn) . '</p>';
|
||||
|
||||
?>
|
3
twsia01-master/pages/wypozyczenia.php
Normal file
3
twsia01-master/pages/wypozyczenia.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="content-wrapper">
|
||||
<h1>Tabela wypożyczenia</h1>
|
||||
</div>
|
48
twsia01-master/style/main.css
Normal file
48
twsia01-master/style/main.css
Normal file
|
@ -0,0 +1,48 @@
|
|||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
.content-wrapper {
|
||||
margin: 15px;
|
||||
padding: 5px;
|
||||
border: 1px solid black;
|
||||
height: calc(100vh - 30px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.img-wrapper {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.table-wrapper {
|
||||
width: calc(100% - 40px);
|
||||
height: 80%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
table, tr, th, td {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
a:hover {
|
||||
color: rgba(24, 24, 24, 0.8);
|
||||
}
|
||||
}
|
||||
tr, th, td {
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
54
twsia01-master/style/style.css
Normal file
54
twsia01-master/style/style.css
Normal file
|
@ -0,0 +1,54 @@
|
|||
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500&display=swap");
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
transition: 0.2s all;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Montserrat", sans-serif;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.main {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: 0.15fr 0.85fr;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-color: #8eb8e5;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sidebar li {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.sidebar li a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.sidebar li:hover {
|
||||
font-size: 18px;
|
||||
background-color: #7c99b4;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
background-color: #6b7f82;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
BIN
twsia01-master/unicorn.png
Normal file
BIN
twsia01-master/unicorn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
Loading…
Reference in a new issue