feat: add database integration and dynamic product listing

Co-authored-by: aider (openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
baiobelfer 2025-09-08 15:23:40 +02:00
parent 3ea70349df
commit 2e8961f0cb
3 changed files with 47 additions and 27 deletions

13
config/database.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$host = 'localhost';
$dbname = 'shoe_store'; // Replace with your database name
$username = 'root'; // Replace with your database username
$password = ''; // Replace with your database password
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Database connection failed: " . $e->getMessage());
}
?>

55
i1.html
View File

@ -2,53 +2,60 @@
<html lang="pl"> <html lang="pl">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Kursy komputerowe</title> <title>Sklep z obuwiem</title>
<link rel="stylesheet" href="css/layout.css"> <link rel="stylesheet" href="css/layout.css">
</head> </head>
<body> <body>
<header> <header>
<img src="imgs/baner.png" alt="kursy komputerowe"> <img src="imgs/baner.png" alt="sklep z obuwiem">
<div class="header-text">Kursy komputerowe</div> <div class="header-text">Sklep z obuwiem</div>
</header> </header>
<nav> <nav>
<a href="i1.html">Strona główna</a> <a href="i1.php">Strona główna</a>
<a href="raty.html">Koszt rat</a> <a href="raty.html">Koszt rat</a>
<a href="https://moje-szkolenia.pl/">Nasz partner</a> <a href="https://moje-szkolenia.pl/">Nasz partner</a>
</nav> </nav>
<main> <main>
<h3>Kursy komputerowe - programowanie</h3> <h3>Oferta obuwia</h3>
<table> <table>
<tr> <tr>
<th>Kurs</th> <th>Model</th>
<th>Czas trwania</th> <th>Kategoria</th>
<th>Cena</th> <th>Cena</th>
<th>Opis</th>
</tr> </tr>
<tr> <?php
<td>React.js</td> require_once 'config/database.php';
<td>4 miesiące</td>
<td>1500 zł</td> try {
</tr> $stmt = $pdo->query("
<tr> SELECT b.model, k.nazwa_kat, b.nazwa, b.cena, b.opis
<td>JavaScript</td> FROM obuwie_buty b
<td>3 miesiące</td> JOIN obuwie_kategorie k ON b.id_kat = k.id_kat
<td>1200 zł</td> ");
</tr>
<tr> while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
<td>HTML + CSS</td> echo "<tr>";
<td>2 miesiące</td> echo "<td>" . htmlspecialchars($row['nazwa']) . "</td>";
<td>800 zł</td> echo "<td>" . htmlspecialchars($row['nazwa_kat']) . "</td>";
</tr> echo "<td>" . number_format($row['cena'], 2) . " zł</td>";
echo "<td>" . htmlspecialchars($row['opis']) . "</td>";
echo "</tr>";
}
} catch (PDOException $e) {
echo "<tr><td colspan='4'>Błąd przy ładowaniu danych: " . $e->getMessage() . "</td></tr>";
}
?>
</table> </table>
<h3>Adres do korespondencji</h3> <h3>Adres do korespondencji</h3>
<ul> <ul>
<li>Adres: Katowice, ul. Mariacka 5</li> <li>Adres: Katowice, ul. Mariacka 5</li>
<li>Telefon: 32 888 88 88</li> <li>Telefon: 32 888 88 88</li>
</ul> </ul>
<a href="mailto:kursy@komputerowe.pl">skontaktuj się</a> <a href="mailto:sklep@obuwie.pl">skontaktuj się</a>
</main> </main>
<footer> <footer>
<p>Autor strony: 99010101010</p> <p>Autor strony: 99010101010</p>

View File

@ -7,11 +7,11 @@
</head> </head>
<body> <body>
<header> <header>
<img src="imgs/baner.png" alt="kursy komputerowe"> <img src="imgs/baner.png" alt="sklep z obuwiem">
<div class="header-text">hello</div> <div class="header-text">Sklep z obuwiem</div>
</header> </header>
<nav> <nav>
<a href="i1.html">Strona główna</a> <a href="i1.php">Strona główna</a>
<a href="raty.html">Koszt rat</a> <a href="raty.html">Koszt rat</a>
<a href="https://moje-szkolenia.pl/">Nasz partner</a> <a href="https://moje-szkolenia.pl/">Nasz partner</a>
</nav> </nav>