Commit iniziale build non versionata
This commit is contained in:
54
index.php
Normal file
54
index.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
require_once "db_conf.php";
|
||||
|
||||
//Esempio query
|
||||
$sql = "SELECT CategoryID,CategoryName,Description FROM Categories";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
|
||||
$id = $_GET["Selezione"]
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Document</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<form id="formCategorie">
|
||||
<select name='Selezione' id='category'>
|
||||
<?php
|
||||
if ($result){
|
||||
while($row = mysqli_fetch_assoc($result)){
|
||||
echo "<option value='" . $row["CategoryID"] . "'>" . $row["CategoryName"] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type=submit value="Cerca">
|
||||
</form>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
if ($result){
|
||||
$queryProdotti = "SELECT ProductID, ProductName, CategoryID, Unit, Price FROM Products";
|
||||
$result = mysqli_query($conn, $queryProdotti);
|
||||
echo "<table><tr><th>ID</th><th>Name</th><th>Unit</th><th>Price</th></tr>";
|
||||
while($row = mysqli_fetch_assoc($result)){
|
||||
if($row["CategoryID"] == $id){
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row["ProductID"] . "</td>";
|
||||
echo "<td>" . $row["ProductName"] . "</td>";
|
||||
echo "<td>" . $row["Unit"] . "</td>";
|
||||
echo "<td>" . $row["Price"] . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
else{
|
||||
echo "Errore nella query: " . mysqli_error($conn);
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user