116 vytváření update záka
This commit is contained in:
parent
f7c7b7ec63
commit
262afa0716
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
<header>
|
<header>
|
||||||
<ul>
|
<nav><ul>
|
||||||
<li><a href="">molestie honestatis error</a> </li>
|
<li><a href="index.php">Úvodní strana</a> </li>
|
||||||
<li><a href="">tempus ex petentium</a> </li>
|
<li><a href="zaci.php">Seznam žáků</a> </li>
|
||||||
<li><a href="">est cursus dictas</a> </li>
|
<li><a href="pridat-zaka.php">Přidat žáka</a> </li>
|
||||||
</ul>
|
</ul></nav>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<h1>Hlavička</h1>
|
<nav><ul>
|
||||||
|
<li><a href="index.php">Úvodní strana</a> </li>
|
||||||
|
<li><a href="zaci.php">Seznam žáků</a> </li>
|
||||||
|
<li><a href="pridat-zaka.php">Přidat žáka</a> </li>
|
||||||
|
</ul></nav>
|
||||||
</header>
|
</header>
|
26
www2databaze/assets/zak.php
Normal file
26
www2databaze/assets/zak.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Získá jednoho žáka z databáze podle id
|
||||||
|
*
|
||||||
|
* @param object $connection - připojení k databázi
|
||||||
|
* @param integer $id - id žáka
|
||||||
|
*
|
||||||
|
* @return mixed asociativní pole, které obsahuje informace o jednom konkrétním žákovi nebo vrátí null, pokud žák nebyl nalezen
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getStudent($connection, $id){
|
||||||
|
$sql = "SELECT * FROM student WHERE id = ?";
|
||||||
|
|
||||||
|
$stmt = mysqli_prepare($connection, $sql);
|
||||||
|
|
||||||
|
if ($stmt === false) {
|
||||||
|
echo mysqli_error($connection);
|
||||||
|
} else {
|
||||||
|
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
return mysqli_fetch_array($result, MYSQLI_ASSOC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,18 +2,12 @@
|
|||||||
global $connection;
|
global $connection;
|
||||||
|
|
||||||
require "assets/database.php";
|
require "assets/database.php";
|
||||||
|
require "assets/zak.php";
|
||||||
|
|
||||||
$connection = connectionDB();
|
$connection = connectionDB();
|
||||||
|
|
||||||
if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
if (isset($_GET["id"]) and is_numeric($_GET["id"])) {
|
||||||
$sql = "SELECT * FROM student WHERE id = ". $_GET["id"];
|
$students = getStudent($connection, $_GET["id"]);
|
||||||
|
|
||||||
$result = mysqli_query($connection, $sql);
|
|
||||||
if ($result === false) {
|
|
||||||
echo mysgli_error($connection);
|
|
||||||
} else {
|
|
||||||
$students = mysqli_fetch_assoc($result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user