correction-ulysse (#2)

# Correction pour les TP1 TP2 et TP3

Je n'ai pas testé la connexion à la DB pour le moment car je ne peux pas me co sur https://dwarves.iut-fbleau.fr/phpmyadmin

Co-authored-by: JARNOUEN DE VILLARTAY Ulysse (SAFRAN AIRCRAFT ENGINES) <ulysse.jarnouen-de-villartay@safrangroup.com>
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-04-15 15:34:46 +02:00
parent 045ec81ae2
commit a4580652f8
22 changed files with 692 additions and 215 deletions
+6 -6
View File
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<body>
<?php
echo "<h1>hello world !!!</h1>";
//phpinfo();
?>
</body>
<body>
<?php
echo "<h1>hello world !!!</h1>";
phpinfo();
?>
</body>
</html>
+35 -10
View File
@@ -1,17 +1,19 @@
<?php
$clients = [
"Luc",
7 => "Paul",
2 =>"Martin",
"Arnaud"
$clients = [
"Luc",
7 => "Paul",
2 =>"Martin",
"Arnaud"
];
var_dump($clients);
$produits = [
20 => "Chemise",
3 => "Pantalon",
10 => "Jupe",
"Veste",
"Blouson"
20 => "Chemise",
3 => "Pantalon",
10 => "Jupe",
"Veste",
"Blouson"
];
$array = ["a","b","c"];
$array[] = "d";
@@ -23,4 +25,27 @@ print_r($clients);
print_r($produits);
print_r($array);
echo "</pre>";
// Exercice 2.1
$tab = [];
$somme = 0;
for ($i = 0; $i < 10; $i++) {
$somme += $i; // somme des entiers de 0 à i
$tab[$i] = $somme; // la clé i contient cette somme
}
print_r($tab);
// Exercice 2.2
for ($debut = 1; $debut <= 50; $debut += 10) {
echo "<p>";
for ($i = $debut; $i < $debut + 10; $i++) {
if ($i % 2 === 0) {
echo "<strong>$i</strong> ";
} else {
echo "<em>$i</em> ";
}
}
echo "</p>";
}
?>
+49 -32
View File
@@ -1,38 +1,55 @@
<?php
include './include/data.inc.php';
include_once './include/data.inc.php';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tp1 - ex3</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<main>
<h2>Exercice 3 : IMC </h2>
<table>
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Email</th>
<th>Taille</th>
<th>Poids</th>
<th>IMC</th>
</tr>
</thead>
<tbody>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tp1 - ex3</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"
>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<main>
<h2>Exercice 3 : IMC </h2>
<table>
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Email</th>
<th>Taille</th>
<th>Poids</th>
<th>IMC</th>
</tr>
</thead>
<tbody>
<?php include_once './include/data.inc.php'; ?>
<?php foreach ($data as $person) : ?>
<?php
$poids = (float) $person['Poids'];
$tailleM = (float) $person['Taille'] / 100;
<!-- À compléter -->
</tbody>
</table>
</main>
</body>
$imc = null;
if ($tailleM > 0) {
$imc = $poids / ($tailleM * $tailleM);
}
?>
<tr class="<?= $imc < 18.5 ? 'underweight' : ($imc < 25 ? 'normal' : 'warning') ?>">
<td><?= $person['Nom'] ?></td>
<td><?= $person['Prenom'] ?></td>
<td><?= $person['Email'] ?></td>
<td><?= $person['Taille'] ?></td>
<td><?= $person['Poids'] ?></td>
<td><?= round($imc, 2) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</main>
</body>
</html>
+20 -4
View File
@@ -1,3 +1,19 @@
<?php
// Generate random values for two six-sided dice.
$die1 = mt_rand(1, 6);
$die2 = mt_rand(1, 6);
$sum = $die1 + $die2;
// Map dice values to matching SVG filenames.
$diceImages = [
1 => 'dice-six-faces-one.svg',
2 => 'dice-six-faces-two.svg',
3 => 'dice-six-faces-three.svg',
4 => 'dice-six-faces-four.svg',
5 => 'dice-six-faces-five.svg',
6 => 'dice-six-faces-six.svg',
];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
@@ -13,12 +29,12 @@
</head>
<body>
<main>
<h5><a href=""> Tirage aléatoire</a></h5>
<h5><a href="./">Tirage aléatoire</a></h5>
<article class="is-center">
<img src='./img/dice-six-faces-five.svg'>
<img src='./img/dice-six-faces-one.svg'>
<img src="./img/<?= $diceImages[$die1] ?>" alt="Dé 1 : <?= $die1 ?>">
<img src="./img/<?= $diceImages[$die2] ?>" alt="Dé 2 : <?= $die2 ?>">
</article>
<h5>Somme = </h5>
<h5>Somme = <?= $sum ?></h5>
</main>
</body>
</html>
+2 -2
View File
@@ -1,5 +1,5 @@
<?php
include './include/favoris.inc.php';
include_once './include/favoris.inc.php';
?>
<!DOCTYPE html>
<html lang="fr">
@@ -17,7 +17,7 @@ include './include/favoris.inc.php';
<body>
<main>
<h2>
Exercice 4 : Favoris
Exercice 4 : Favoris
</h2>
<!-- À compléter -->
+4 -4
View File
@@ -1,7 +1,7 @@
<?php
function createPassword($n,$alphabet){
$length = strlen($alphabet);
$password = "";
return $password;
function createPassword($n,$alphabet) {
$length = strlen($alphabet);
$password = "";
return $password;
}
?>
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
include './include/fonction.php';
include_once './include/fonction.php';
$alphabet = "@#!*^&azertyuiopqsdfghjkklmwxcvbnAZERTYUIOPLMKJHGFDSQWXCVBN1234567890";
?>
<!DOCTYPE html>