Backend óra (2024. 11. 25.)
This commit is contained in:
parent
099bd2a5ce
commit
8361384e9e
13
Suli/13.b/Backend/2024. 11. 25/config.php
Normal file
13
Suli/13.b/Backend/2024. 11. 25/config.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
$server = "localhost";
|
||||
$user = "root";
|
||||
$pwd = "";
|
||||
$db = "13b2";
|
||||
|
||||
$conn = new mysqli($server, $user, $pwd, $db);
|
||||
|
||||
if ($conn -> connect_errno) {
|
||||
die("Nem sikerült a kapcsolat kiépítése: ".$conn -> connect_error);
|
||||
}
|
||||
|
||||
?>
|
14
Suli/13.b/Backend/2024. 11. 25/html.php
Normal file
14
Suli/13.b/Backend/2024. 11. 25/html.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="hu">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Szűrés</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST">
|
||||
<input type="text" name="szures">
|
||||
<button type="submit">Szűrés</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
35
Suli/13.b/Backend/2024. 11. 25/index.php
Normal file
35
Suli/13.b/Backend/2024. 11. 25/index.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
require_once("config.php");
|
||||
|
||||
if (isset($_POST["szures"])) {
|
||||
|
||||
$felt = $_POST["szures"];
|
||||
$sql = "SELECT cim, jegyar FROM film WHERE cim LIKE '%".$felt."%' ORDER BY cim ";
|
||||
|
||||
$result = $conn -> query($sql);
|
||||
|
||||
if ($result -> num_rows > 0) {
|
||||
$i = 1;
|
||||
echo "<table>
|
||||
<tr><th>Ssz.</th>
|
||||
<th>Cím.</th>
|
||||
<th>Ár.</th>
|
||||
<tr>";
|
||||
while ($row = $result -> fetch_object()) {
|
||||
echo "<tr>
|
||||
<td>".$i++."</td>
|
||||
<td>".$row -> cim."</td>
|
||||
<td>".$row -> jegyar."</td>
|
||||
</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
echo "Nincs adat";
|
||||
}
|
||||
|
||||
require_once("html.php");
|
||||
$conn -> close()
|
||||
?>
|
Loading…
Reference in New Issue
Block a user