Compare commits
10 Commits
528069e819
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2157c04381 | |||
| 330feed202 | |||
| caed718bc6 | |||
| 5f276c6ba5 | |||
| 9855ecf111 | |||
| e13e8a6004 | |||
| 9cb55bd534 | |||
| 913dfdb403 | |||
| 585f91a6d4 | |||
| 7c6b9e0c44 |
@@ -10,7 +10,7 @@ class User{
|
||||
$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 = [];
|
||||
|
||||
fgets($file);
|
||||
@@ -25,7 +25,6 @@ fclose($file);
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TechStore</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
@@ -35,14 +34,12 @@ fclose($file);
|
||||
<th>ID Utente</th>
|
||||
<th>Nominativo</th>
|
||||
<th>Email</th>
|
||||
<th>Link del cazzo</th>
|
||||
</tr>
|
||||
<?php
|
||||
for($i=0; $i<count($utenti); $i++){
|
||||
echo "<tr><td>" . $utenti[$i]->id . "</td><td>" . $utenti[$i]->name . "</td><td><a href=\"mailto:" . $utenti[$i]->email ."\">" . $utenti[$i]->email . "</a></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>
|
||||
</body>
|
||||
</html>
|
||||
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