update
This commit is contained in:
@@ -1,11 +1,42 @@
|
||||
<?php
|
||||
include_once "kapcsolat.php";
|
||||
|
||||
$tabla = $kapcsolat->readAll($kapcsolat->getDBC(), "comics");
|
||||
$tabla = [];
|
||||
//print_r($tabla);
|
||||
|
||||
$keys = ["id", "Kiadó", "Cím", "Sorozat", "Író", "Rajzoló", "Műfaj", "Szereplők"];
|
||||
|
||||
if(isset($_POST['passed'])){
|
||||
$tabla = $kapcsolat->readAll($kapcsolat->getDBC(), "comics");
|
||||
print_r($tabla);
|
||||
}
|
||||
|
||||
|
||||
//adatok rogzitese:
|
||||
$adatok = [];
|
||||
try {
|
||||
if (isset($_POST['rogzit'])) {
|
||||
foreach ($_POST as $key => $value) {
|
||||
if($key == 'rogzit' || $key == 'keres') continue;
|
||||
if($value == null) throw new Exception("Nem adott meg minden adatot");
|
||||
if ($key <> 'insert') {
|
||||
$adatok[$key] = $value;
|
||||
}
|
||||
}
|
||||
print_r($adatok);
|
||||
$kapcsolat->insert($kapcsolat->getDBC(), 'comics', $adatok);
|
||||
}
|
||||
} catch (Exception) {
|
||||
echo "Nem adott meg minden adatot!";
|
||||
}
|
||||
|
||||
if (isset($_POST['keres'])) {
|
||||
if($_POST['keres'] <> ""){
|
||||
$adat = $_POST['keres'];
|
||||
$tabla = $kapcsolat->kereses($kapcsolat->getDBC(), 'comics', $adat);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -21,66 +52,68 @@
|
||||
<div class="container-fluid">
|
||||
<h1 class="cim">Képregényeim</h1><br>
|
||||
<div class="flexbox-container">
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Kiadó:
|
||||
<form method="post" name="rogzit">
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Kiadó:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="Kiadó" id="kiado">
|
||||
<input class="gomb" type="submit" name="rogzit" value="Rögzít"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="kiado" id="kiado">
|
||||
<button>Rögzít</button>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Cím:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="Cím" id="cim">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Cím:
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Sorozat:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="number" name="Sorozat" id="sorozat">
|
||||
Keress rá egy szereplőre
|
||||
</div>
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="cim" id="cim">
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Író:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="Író" id="iro">
|
||||
<input type="text" name="keres" id="keres">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Sorozat:
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Rajzoló:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="Rajzoló" id="rajzolo">
|
||||
<button>Keresés</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="number" name="sorozat" id="sorozat">
|
||||
Keress rá egy szereplőre
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Műfaj:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="Műfaj" id="mufaj">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Író:
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Szereplők:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="Szereplők" id="szereplok">
|
||||
</div>
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="iro" id="iro">
|
||||
<input type="text" name="keres" id="keres">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Rajzoló:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="rajzolo" id="rajzolo">
|
||||
<button>Keresés</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Műfaj:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="mufaj" id="mufaj">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sor">
|
||||
<div class="title">
|
||||
Szereplők:
|
||||
</div>
|
||||
<div class="bevitel">
|
||||
<input type="text" name="szereplok" id="szereplok">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<div class="tabla">
|
||||
@@ -108,7 +141,9 @@
|
||||
</table>
|
||||
</div>
|
||||
<div align="right">
|
||||
<button>Lekérdezés</button>
|
||||
<form method="post" action="index.php">
|
||||
<button type="submit" name="passed" id="passed">Lekérdézés</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,7 @@ class Kapcsolat{
|
||||
return $this->dbc;
|
||||
}
|
||||
|
||||
//tabla beolvasasa
|
||||
|
||||
public function readAll($dbc, $table) {
|
||||
$sql = "SELECT * FROM $table;";
|
||||
$utasitas = $dbc->prepare($sql);
|
||||
@@ -42,6 +42,14 @@ class Kapcsolat{
|
||||
return $utasitas->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
public function kereses($dbc, $table, $szereplo) {
|
||||
$sql = "SELECT * FROM $table WHERE Szereplők = '$szereplo'";
|
||||
$utasitas = $dbc->prepare($sql);
|
||||
$utasitas->execute();
|
||||
|
||||
return $utasitas->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
//egy rekord torlese
|
||||
public function deleteOne($dbc, $table, $id) {
|
||||
$sql = "DELETE FROM $table WHERE id=$id;";
|
||||
@@ -77,18 +85,6 @@ class Kapcsolat{
|
||||
$utasitas = $dbc->prepare($sql);
|
||||
$utasitas->execute();
|
||||
}
|
||||
|
||||
public function lekerdezes($tabla, $keys){
|
||||
foreach ($tabla as $key => $value) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $key2 => $value2) {
|
||||
if($value2 == "id"){
|
||||
continue;
|
||||
}
|
||||
echo "<td>".$value[$value2]."</td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$kapcsolat = new Kapcsolat();
|
||||
|
||||
BIN
kepregeny/sql/kepregeny/comics.frm
Normal file
BIN
kepregeny/sql/kepregeny/comics.frm
Normal file
Binary file not shown.
BIN
kepregeny/sql/kepregeny/comics.ibd
Normal file
BIN
kepregeny/sql/kepregeny/comics.ibd
Normal file
Binary file not shown.
2
kepregeny/sql/kepregeny/db.opt
Normal file
2
kepregeny/sql/kepregeny/db.opt
Normal file
@@ -0,0 +1,2 @@
|
||||
default-character-set=utf8mb4
|
||||
default-collation=utf8mb4_hungarian_ci
|
||||
73
kepregeny/sql/kepregeny/kepregeny.sql
Normal file
73
kepregeny/sql/kepregeny/kepregeny.sql
Normal file
@@ -0,0 +1,73 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.1.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Gép: 127.0.0.1
|
||||
-- Létrehozás ideje: 2022. Jún 06. 15:01
|
||||
-- Kiszolgáló verziója: 10.4.22-MariaDB
|
||||
-- PHP verzió: 8.1.2
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Adatbázis: `kepregeny`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Tábla szerkezet ehhez a táblához `comics`
|
||||
--
|
||||
|
||||
CREATE TABLE `comics` (
|
||||
`id` int(200) NOT NULL,
|
||||
`Kiadó` varchar(200) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,
|
||||
`Cím` varchar(200) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,
|
||||
`Sorozat` int(200) NOT NULL,
|
||||
`Író` varchar(200) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,
|
||||
`Rajzoló` varchar(200) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,
|
||||
`Műfaj` varchar(200) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,
|
||||
`Szereplők` varchar(200) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_hungarian_ci;
|
||||
|
||||
--
|
||||
-- A tábla adatainak kiíratása `comics`
|
||||
--
|
||||
|
||||
INSERT INTO `comics` (`id`, `Kiadó`, `Cím`, `Sorozat`, `Író`, `Rajzoló`, `Műfaj`, `Szereplők`) VALUES
|
||||
(1, 'Elek Mihály Kiadó', 'Spider-Man', 6, 'Elek Mihály', 'Elek Mihály', 'Akció', 'Peter Parker'),
|
||||
(5, 'Elek Mihály Kiadó', 'Spider-Man', 6, 'Elek Mihály', 'Elek Mihály', 'Akció', 'Mary Jane'),
|
||||
(6, 'Mihály Elek Kiadó', 'Vasember', 1, 'Mihály Elek', 'Mihály Elek', 'Akció', 'Tony Stark');
|
||||
|
||||
--
|
||||
-- Indexek a kiírt táblákhoz
|
||||
--
|
||||
|
||||
--
|
||||
-- A tábla indexei `comics`
|
||||
--
|
||||
ALTER TABLE `comics`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- A kiírt táblák AUTO_INCREMENT értéke
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT a táblához `comics`
|
||||
--
|
||||
ALTER TABLE `comics`
|
||||
MODIFY `id` int(200) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
@@ -29,8 +29,9 @@ table, th, td{
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
button{
|
||||
button, .gomb{
|
||||
border-radius: 5px;
|
||||
width: 6%;
|
||||
}
|
||||
|
||||
.cim{
|
||||
@@ -49,17 +50,10 @@ button{
|
||||
margin-left: 10%;
|
||||
}
|
||||
|
||||
.bevitel input{
|
||||
.bevitel input:first-child{
|
||||
margin-right: 3%;
|
||||
}
|
||||
|
||||
.sor{
|
||||
margin-bottom: 1.5%;
|
||||
}
|
||||
|
||||
.tabla{
|
||||
/*float: left;*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user