objektumok

This commit is contained in:
2022-04-13 09:01:16 +02:00
parent 044ec5f379
commit ff269ba085
37 changed files with 499 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<?php
include "kozos/kapcsolat.php";
try {
$kapcsolat->deleteOne($kapcsolat->getDBC(), 'pizzak', $_GET['id']);
header('location: index.php');
} catch (Exception $exc) {
header("Location: hiba.php?hiba=" . $exc->getMessage());
}

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html>
<?php
?>
<html>
<head>
<meta charset="UTF-8">
<title>Hiba</title>
<link href="../kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!--bootstrap card-ot ghasználva a oldal közepén jelenik meg a hibaüzenet és részletes leírása-->
<div class="container-fluid d-flex justify-content-center align-items-center text-center mt-5" style="height: 100vh;" >
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Hiba</h5>
<h6 class="card-subtitle mb-2 text-muted">Hiba leírása</h6>
<p class="card-text">
<?php
echo "Törlési hiba: " . $_GET['hiba'];
?></p>
<a href="index.php" class="btn btn-info">vissza</a>
</div>
</div>
</div>
<script src="../kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -0,0 +1,50 @@
<!DOCTYPE html>
<?php
include "kozos/kapcsolat.php";
//$kapcsolat = new Kapcsolat();
$adatok = $kapcsolat->readAll($kapcsolat->getDBC(), 'pizzak');
?>
<html>
<head>
<meta charset="UTF-8">
<title>Pizzák</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container-fluid w-75">
<a class="btn btn-info" href="insert.php">Hozzáadás</a>
<table class="table table-info table-striped my-3" >
<tr>
<?php foreach ($adatok[0] as $key => $value) : ?>
<th><?= $key; ?></th>
<?php endforeach; ?>
<!--Műveletek oszlop -->
<th colspan='3' style="text-align: center; width:20%;" >Műveletek</th>
</tr>
<?php foreach ($adatok as $sor) : ?>
<tr>
<?php foreach ($sor as $key => $value) : ?>
<?php if ($key == 'kep') : ?>
<td><img class="img-thumbnail" src="img/<?= $value; ?>" /></td>
<?php else : ?>
<td><?= $value; ?></td>
<?php endif; ?>
<?php endforeach; ?>
<!--Műveletek létrehozás id oszlopra -->
<div >
<td><a class="btn btn-info" href="view.php?id=<?= $sor['id']; ?>"> Megtekint </a></td>
<td><a class="btn btn-info" href="update.php?id=<?= $sor['id']; ?>"> Szerkeszt </a></td>
<td><a class="btn btn-info" href="delete.php?id=<?= $sor['id']; ?>"> Töröl </a></td>
</div>
</tr>
<?php endforeach; ?>
</table>
<a class="btn btn-info" href="../index.php">Vissza</a>
</div>
<script src="kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<!DOCTYPE html>
<?php
include "kozos/kapcsolat.php";
$adatok = [];
if (isset($_POST['insert'])) {
foreach ($_POST as $key => $value) {
if ($key <> 'insert') {
$adatok[$key] = $value;
}
}
$kapcsolat->insert($kapcsolat->getDBC(), 'pizzak', $adatok);
header('Location: index.php');
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Pizzák</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container w-50">
<form name="uj" method="POST">
<div class="mb-3">
<label for="nev" class="form-label">Név</label>
<input type="text" class="form-control" id="nev" name="nev" placeholder="">
</div>
<div class="mb-3">
<label for="feltetek" class="form-label">Feltétek</label>
<input type="text" class="form-control" id="feltetek" name="feltetek" placeholder="">
</div>
<div class="mb-3">
<label for="ar" class="form-label">Ár</label>
<input type="number" class="form-control" id="ar" name="ar" placeholder="">
</div>
<div class="mb-3">
<label for="kep" class="form-label">Kép(Csak a fájl nevét add meg! pl.: napoli.jpg) </label>
<input type="text" class="form-control" id="kep" name="kep" placeholder="">
</div>
<input class="btn btn-info" type="submit" name="insert" value="Beszúrás" />
<a class="btn btn-info" href="index.php">Vissza</a>
</form>
</div>
<script src="kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,83 @@
<?php
class Kapcsolat{
//adattagok
private $host = 'localhost';
private $dbuser = 'root';
private $password = '';
private $dbname = 'pizzeria';
private $dbc;
//konstruktor
public function __construct(){
try {
$datasourcename = "mysql:host=$this->host;dbname=$this->dbname";
//echo $datasourcename . "<hr>";
$options = [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$this->dbc = new PDO($datasourcename, $this->dbuser, $this->password, $options);
} catch (PDOException $exc) {
echo "Kapcsolódási hiba:" . $exc->getMessage();
}
}
//metodusok
public function getDBC(){
return $this->dbc;
}
//tabla beolvasasa
public function readAll($dbc, $table) {
$sql = "SELECT * FROM $table;";
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
return $utasitas->fetchAll(PDO::FETCH_ASSOC);
}
//egy rekord beolvasasa
public function readOne($dbc, $table, $id) {
$sql = "SELECT * FROM $table WHERE id=$id;";
$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;";
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
}
// Mivel az id automatikusan generalodik ezért a id értéke helyett NULL értéket adunk meg beillesztéskor
//uj rekord beszurasa
public function insert($dbc, $table, $datas) {
$sql = "INSERT INTO $table VALUES (NULL, '";
foreach ($datas as $value) {
$sql .= $value . "', '";
}
$sql = substr($sql, 0, strlen($sql) - 3);
$sql .= ");";
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
}
//rekord adatinak szerkesztese
public function update($dbc, $table, $datas) {
$sql = "UPDATE $table SET ";
//print_r($datas);
foreach ($datas as $key => $value) {
if ($key <> 'id') {
$sql .= $key . "='" . $value . "', ";
}
}
$sql = substr($sql, 0, strlen($sql) - 2);
$sql .= " WHERE id =" . $datas['id'] . ";";
//print_r($sql);
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
}
}
$kapcsolat = new Kapcsolat();
?>

View File

@@ -0,0 +1,71 @@
--
-- Script was generated by Devart dbForge Studio 2020 for MySQL, Version 9.0.689.0
-- Product home page: http://www.devart.com/dbforge/mysql/studio
-- Script date 2022. 03. 15. 23:47:58
-- Server version: 10.4.20
-- Client version: 4.1
--
--
-- Disable foreign keys
--
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
--
-- Set SQL mode
--
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
--
-- Set character set the client will use to send SQL statements to the server
--
SET NAMES 'utf8';
DROP DATABASE IF EXISTS pizzeria;
CREATE DATABASE IF NOT EXISTS pizzeria
CHARACTER SET utf8
COLLATE utf8_hungarian_ci;
--
-- Set default database
--
USE pizzeria;
--
-- Create table `pizzak`
--
CREATE TABLE IF NOT EXISTS pizzak (
id INT(11) NOT NULL AUTO_INCREMENT,
nev VARCHAR(100) DEFAULT NULL,
feltetek TEXT DEFAULT NULL,
ar INT(11) DEFAULT NULL,
kep VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 11,
AVG_ROW_LENGTH = 2340,
CHARACTER SET utf8,
COLLATE utf8_hungarian_ci;
--
-- Dumping data for table pizzak
--
INSERT INTO pizzak VALUES
(2, 'Calzone vékony pizza', 'Gomba, Mozzarella, paradicsom szósz, pármai sonka', 1852, 'calzone.jpg'),
(3, 'Capricciosa vékony pizza', 'Gomba, Mozzarella, Paradicsom, articsóka, paradicsom szósz, pármai sonka', 2150, 'capricciosa.jpg'),
(4, 'Margherita vékony pizza', 'Mozzarella, Paradicsom, oregánó, paradicsom szósz', 1650, 'margherita.jpg'),
(5, 'Napoletana vékony pizza', 'Mozzarella, Tonhal, paradicsom szósz', 1850, 'napoletana.jpg'),
(6, 'Quattro Formaggi vékony pizza', 'Parmezán, Rokfort, Trappista, tejfölös alap', 1950, 'quattroformaggi.jpg'),
(7, 'Pugliese vékony pizza', 'Lilahagyma, Mozzarella, paradicsom szósz', 1950, 'pugliese.jpg');
--
-- Restore previous SQL mode
--
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
--
-- Enable foreign keys
--
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

View File

@@ -0,0 +1,7 @@
browser.id=Chrome.INTEGRATED
copy.src.files=false
copy.src.on.open=false
copy.src.target=
index.file=index.php
run.as=LOCAL
url=http://localhost/DolgozatF2

View File

@@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_80
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>DolgozatF2</name>
</data>
</configuration>
</project>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -0,0 +1,71 @@
--
-- Script was generated by Devart dbForge Studio 2020 for MySQL, Version 9.0.689.0
-- Product home page: http://www.devart.com/dbforge/mysql/studio
-- Script date 2022. 03. 15. 23:47:58
-- Server version: 10.4.20
-- Client version: 4.1
--
--
-- Disable foreign keys
--
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
--
-- Set SQL mode
--
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
--
-- Set character set the client will use to send SQL statements to the server
--
SET NAMES 'utf8';
DROP DATABASE IF EXISTS pizzeria;
CREATE DATABASE IF NOT EXISTS pizzeria
CHARACTER SET utf8
COLLATE utf8_hungarian_ci;
--
-- Set default database
--
USE pizzeria;
--
-- Create table `pizzak`
--
CREATE TABLE IF NOT EXISTS pizzak (
id INT(11) NOT NULL AUTO_INCREMENT,
nev VARCHAR(100) DEFAULT NULL,
feltetek TEXT DEFAULT NULL,
ar INT(11) DEFAULT NULL,
kep VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 11,
AVG_ROW_LENGTH = 2340,
CHARACTER SET utf8,
COLLATE utf8_hungarian_ci;
--
-- Dumping data for table pizzak
--
INSERT INTO pizzak VALUES
(2, 'Calzone vékony pizza', 'Gomba, Mozzarella, paradicsom szósz, pármai sonka', 1852, 'calzone.jpg'),
(3, 'Capricciosa vékony pizza', 'Gomba, Mozzarella, Paradicsom, articsóka, paradicsom szósz, pármai sonka', 2150, 'capricciosa.jpg'),
(4, 'Margherita vékony pizza', 'Mozzarella, Paradicsom, oregánó, paradicsom szósz', 1650, 'margherita.jpg'),
(5, 'Napoletana vékony pizza', 'Mozzarella, Tonhal, paradicsom szósz', 1850, 'napoletana.jpg'),
(6, 'Quattro Formaggi vékony pizza', 'Parmezán, Rokfort, Trappista, tejfölös alap', 1950, 'quattroformaggi.jpg'),
(7, 'Pugliese vékony pizza', 'Lilahagyma, Mozzarella, paradicsom szósz', 1950, 'pugliese.jpg');
--
-- Restore previous SQL mode
--
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
--
-- Enable foreign keys
--
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<?php
include "kozos/kapcsolat.php";
if (isset($_POST['update'])) {
$akt = array_pop($_POST);
$kapcsolat->update($kapcsolat->getDBC(), 'pizzak', $_POST);
header('Location: index.php');
} else {
$akt = $kapcsolat->readOne($kapcsolat->getDBC(), 'pizzak', $_GET['id']);
$akt = $akt[0];
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Alkalmozottak</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container w-50">
<form name="uj" method="POST">
<input hidden type="text" class="form-control" id="id" name="id" value="<?= $akt['id']; ?>" placeholder="">
<div class="mb-3">
<label for="nev" class="form-label">Név</label>
<input type="text" class="form-control" id="nev" name="nev" value="<?= $akt['nev']; ?>" placeholder="">
</div>
<div class="mb-3">
<label for="feltetek" class="form-label">Feltétek</label>
<input type="text" class="form-control" id="feltetek" name="feltetek" value="<?= $akt['feltetek']; ?>" placeholder="">
</div>
<div class="mb-3">
<label for="ar" class="form-label">Ár</label>
<input type="number" class="form-control" id="ar" name="ar"value="<?= $akt['ar']; ?>" placeholder="">
</div>
<div class="mb-3">
<label for="kep" class="form-label">Kép(Csak a fájl nevét add meg! pl.: napoli.jpg) </label>
<input type="text" class="form-control" id="kep" name="kep" value="<?= $akt['kep']; ?>" placeholder="">
</div>
<input class="btn btn-info" type="submit" name="update" value="Frissít" value="" />
<a class="btn btn-info" href="index.php">Vissza</a>
</form>
</div>
<script src="kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<?php
include "kozos/kapcsolat.php";
$adatok = $kapcsolat->readOne($kapcsolat->getDBC(), 'pizzak', $_GET['id']);
?>
<html>
<head>
<meta charset="UTF-8">
<title>Alkalmozottak</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<ul>
<?php foreach ($adatok[0] as $key => $value) : ?>
<li class="my-3"><?= "<b>$key: </b> $value"; ?> </li>
<?php endforeach; ?>
<a class="btn btn-info" href="index.php">Vissza</a>
</ul>
</div>
<script src="kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>