Compare commits
12 Commits
52749506a6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2157c04381 | |||
| 330feed202 | |||
| caed718bc6 | |||
| 5f276c6ba5 | |||
| 9855ecf111 | |||
| e13e8a6004 | |||
| 9cb55bd534 | |||
| 913dfdb403 | |||
| 585f91a6d4 | |||
| 7c6b9e0c44 | |||
| 528069e819 | |||
| 3a0e5ecab0 |
@@ -10,7 +10,7 @@ class User{
|
|||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$file = fopen("data/clienti.csv", "r") or die("Non riesco a leggere il file, controlla che esista brutto rimbambito");
|
$file = fopen("data/clienti.csv", "r") or die("Non riesco a leggere il file, controlla che esista");
|
||||||
$utenti = [];
|
$utenti = [];
|
||||||
|
|
||||||
fgets($file);
|
fgets($file);
|
||||||
@@ -25,8 +25,8 @@ fclose($file);
|
|||||||
<html lang="it">
|
<html lang="it">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>TechStore</title>
|
<title>TechStore</title>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<table>
|
<table>
|
||||||
@@ -34,11 +34,10 @@ fclose($file);
|
|||||||
<th>ID Utente</th>
|
<th>ID Utente</th>
|
||||||
<th>Nominativo</th>
|
<th>Nominativo</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Link del cazzo</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
for($i=0; $i<count($utenti); $i++){
|
for($i=0; $i<count($utenti); $i++){
|
||||||
echo "<tr><td>" . $utenti[$i]->id . "</td></tr>";
|
echo "<tr><td>" . $utenti[$i]->id . "</td><td><a href=\"ordini.php?id=" . $utenti[$i]->id ."\">" . $utenti[$i]->name . "</a></td><td><a href=\"mailto:" . $utenti[$i]->email ."\">" . $utenti[$i]->email . "</a></tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
48
ordini.php
Normal file
48
ordini.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
class User{
|
||||||
|
public $id;
|
||||||
|
public $product;
|
||||||
|
public $importo;
|
||||||
|
|
||||||
|
function __construct($id, $productName, $importo){
|
||||||
|
$this->id = $id;
|
||||||
|
$this->product = $productName;
|
||||||
|
$this->importo = $importo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$requestedId = $_GET['id'];
|
||||||
|
$file = fopen("data/ordini.csv", "r") or die("Non riesco a leggere il file, controlla che esista");
|
||||||
|
$ordini = [];
|
||||||
|
|
||||||
|
fgets($file);
|
||||||
|
while (($linea = fgets($file)) !== false) {
|
||||||
|
$campi = explode(",", $linea);
|
||||||
|
if($campi[1] == $requestedId){
|
||||||
|
array_push($ordini, new User($campi[0], $campi[2], floatval($campi[3])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($file);
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="it">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>TechStore - Ordini Utente <?php echo $requestedId; ?></title>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p><a href="index.php">Torna alla lista</a></p>
|
||||||
|
<?php
|
||||||
|
if(count($ordini) == 0){
|
||||||
|
echo "<p>Nessun ordine associato all'utente</p>";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "<table><tr><th>ID Ordine</th><th>Prodotto</th><th>Importo</th></tr>";
|
||||||
|
for($i=0; $i<count($ordini); $i++){
|
||||||
|
echo "<tr><td>" . $ordini[$i]->id . "</td><td>" . $ordini[$i]->product . "</td><td>" . number_format($ordini[$i]->importo,2,",",".") . "€</td></tr>";
|
||||||
|
}
|
||||||
|
echo "</table>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user