mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-03-29 20:21:20 +00:00
Aggiunta pagina web base (mostra tabella con tutti i campi di Products)
This commit is contained in:
66
index.php
Normal file
66
index.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
include 'db_conf.php';
|
||||
|
||||
// Query per ottenere tutti i prodotti
|
||||
$sql = "SELECT * FROM Products";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result === false) {
|
||||
die("Errore nella query: " . $conn->error);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TechStore - Prodotti</title>
|
||||
<style>
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Prodotti TechStore</h1>
|
||||
|
||||
<?php if ($result->num_rows > 0): ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
// Ottieni i nomi delle colonne
|
||||
$fields = $result->fetch_fields();
|
||||
foreach ($fields as $field) {
|
||||
echo "<th>" . htmlspecialchars($field->name) . "</th>";
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($row = $result->fetch_assoc()): ?>
|
||||
<tr>
|
||||
<?php foreach ($row as $value): ?>
|
||||
<td><?php echo htmlspecialchars($value); ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p>Nessun prodotto trovato.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $conn->close(); ?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user