This commit is contained in:
2022-04-07 14:54:21 +02:00
commit 044ec5f379
55 changed files with 1220 additions and 0 deletions

134
sql/db_elso.sql Normal file
View File

@@ -0,0 +1,134 @@
--
-- 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 2021. 12. 13. 9:26:41
-- Server version: 10.4.21
-- 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 db_elso;
CREATE DATABASE IF NOT EXISTS db_elso
CHARACTER SET utf8
COLLATE utf8_hungarian_ci;
--
-- Set default database
--
USE db_elso;
--
-- Create table `firms`
--
CREATE TABLE IF NOT EXISTS firms (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
address VARCHAR(255) NOT NULL,
postcode INT(11) NOT NULL,
remark TEXT DEFAULT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 14,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8,
COLLATE utf8_hungarian_ci;
--
-- Create table `employees`
--
CREATE TABLE IF NOT EXISTS employees (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
address VARCHAR(255) NOT NULL,
salary INT(10) NOT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 16,
AVG_ROW_LENGTH = 5461,
CHARACTER SET latin1,
COLLATE latin1_swedish_ci;
--
-- Create table `workers`
--
CREATE TABLE IF NOT EXISTS workers (
id INT(11) NOT NULL AUTO_INCREMENT,
empID INT(11) NOT NULL,
firmID INT(11) DEFAULT NULL,
begin DATE DEFAULT NULL,
end DATE DEFAULT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 8,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8,
COLLATE utf8_hungarian_ci;
--
-- Create foreign key
--
ALTER TABLE workers
ADD CONSTRAINT FK_workers_employees_id FOREIGN KEY (empID)
REFERENCES employees(id) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Create foreign key
--
ALTER TABLE workers
ADD CONSTRAINT FK_workers_firms_id FOREIGN KEY (firmID)
REFERENCES firms(id);
--
-- Dumping data for table firms
--
INSERT INTO firms VALUES
(1, 'Zabhegyező Kft', 'Zabhegy', 4556, ' :-(((( ++++'),
(2, 'Réparudi Bt.', 'Salátaföld2', 5005, 'Szántás alatt'),
(4, 'ABC Zrt.', 'Egerszalók', 2451, ':-)'),
(13, 'Nagy Forma Bt.', 'Debrecen', 4031, 'yxncybnxcbxybcmyxbcyxbcmybxcm,byxy');
--
-- Dumping data for table employees
--
INSERT INTO employees VALUES
(7, 'Kiss Kati', 'Szarvas', 5000000),
(9, 'Tóth Miklós', 'Debrecen', 35000000),
(10, 'Nagy Adelka', 'Szarvas', 35000000);
--
-- Dumping data for table workers
--
INSERT INTO workers VALUES
(2, 9, 1, '2019-04-17', NULL),
(3, 7, 2, '2019-04-01', '2019-05-02'),
(4, 10, 2, '2019-05-08', NULL),
(6, 10, 4, '2021-01-01', '2021-11-30'),
(7, 7, 1, '2021-11-26', '2021-11-18');
--
-- 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,37 @@
<!DOCTYPE html>
<?php
include "../kozos/kapcsolat.php";
$alkalmazottak = readAll($dbc,'employees');
?>
<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">
<table class="table table-success table-striped my-3" >
<tr>
<?php foreach ($alkalmazottak[0] as $key => $value) : ?>
<th><?= $key; ?></th>
<?php endforeach; ?>
</tr>
<?php foreach ($alkalmazottak as $sor) : ?>
<tr>
<?php foreach ($sor as $value) : ?>
<td><?= $value; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<a href="index.php" class="btn btn-info" role="button">Vissza</a>
</div>
<script src="../kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<?php
include "../kozos/kapcsolat.php";
$alkalmazottak = readAll($dbc, 'firms');
?>
<html>
<head>
<meta charset="UTF-8">
<title>Cégek</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<table class="table table-success table-striped my-3" >
<tr>
<?php foreach ($alkalmazottak[0] as $key => $value) : ?>
<th><?= $key; ?></th>
<?php endforeach; ?>
</tr>
<?php foreach ($alkalmazottak as $sor) : ?>
<tr>
<?php foreach ($sor as $value) : ?>
<td><?= $value; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<a href="index.php" class="btn btn-info" role="button">Vissza</a>
</div>
<script src="../kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

30
sql/dbphp1/index.php Normal file
View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<?php
include "kozos/kapcsolat.php";
$sql = "SHOW TABLES;";
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
$tablak = $utasitas->fetchAll(PDO::FETCH_COLUMN);
//print_r($tablak);
?>
<html>
<head>
<meta charset="UTF-8">
<title>Adatbázis kezelés</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<table class="table table-success table-striped my-3" >
<?php foreach ($tablak as $tabla) : ?>
<tr>
<td><?= $tabla; ?></td><td> <a href=<?="/$tabla/". $tabla . ".php"; ?>>Megjelenít </a> </td>
</tr>
<?php endforeach; ?>
</table>
</div>
<script src="kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

7
sql/dbphp1/kozos/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7
sql/dbphp1/kozos/bootstrap.min.js vendored Normal file

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,29 @@
<?php
$host = 'localhost';
$dbuser = 'root';
$password = '';
$dbname = 'db_elso';
try {
$datasourcename = "mysql:host=$host;dbname=$dbname";
echo $datasourcename . "<hr>";
$options = [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$dbc = new PDO($datasourcename, $dbuser, $password, $options);
} catch (PDOException $exc) {
echo "Kapcsolódási hiba:" . $exc->getMessage();
}
function readAll($dbc, $table){
$sql = "SELECT * FROM $table;";
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
return $utasitas->fetchAll(PDO::FETCH_ASSOC);
}
function readOne($dbc, $table, $id){
$sql = "SELECT * FROM $table WHERE id=$id;";
$utasitas = $dbc->prepare($sql);
$utasitas->execute();
return $utasitas->fetchAll(PDO::FETCH_ASSOC);
}

View File

@@ -0,0 +1,7 @@
browser.id=SL[/Browsers/FirefoxBrowser
copy.src.files=false
copy.src.on.open=false
copy.src.target=D:\\xampp\\htdocs\\PhpProject1
index.file=index.php
run.as=LOCAL
url=http://localhost/dbphp1/

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
</open-files>
</project-private>

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>dbphp1</name>
</data>
</configuration>
</project>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<?php
include "../kozos/kapcsolat.php";
$alkalmazottak = readAll($dbc, 'workers');
?>
<html>
<head>
<meta charset="UTF-8">
<title>Munkaviszonyok</title>
<link href="kozos/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<table class="table table-success table-striped my-3" >
<tr>
<?php foreach ($alkalmazottak[0] as $key => $value) : ?>
<th><?= $key; ?></th>
<?php endforeach; ?>
</tr>
<?php foreach ($alkalmazottak as $sor) : ?>
<tr>
<?php foreach ($sor as $value) : ?>
<td><?= $value; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<a href="index.php" class="btn btn-info" role="button">Vissza</a>
</div>
<script src="../kozos/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>