File "code_023.php"
Full Path: /home/analogde/www/New folder/code_023.php
File size: 30.87 KB
MIME-type: text/x-php
Charset: utf-8
<?php
$host = "analogdepat.mysql.db";
$dbname = "analogdepat";
$username = "analogdepat";
$password = "Un92pac007";
$conn = new mysqli($host, $username, $password, $dbname);
// Vérification de la connexion
if ($conn->connect_error) {
die("Erreur de connexion : " . $conn->connect_error);
}
// Récupération des données de la table
$sql = "SELECT id, column_name, created_at FROM table_DB_planning";
$result = $conn->query($sql);
$entries = [];
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$entries[] = $row;
}
}
// Fermeture de la connexion
$conn->close();
/******************************************/
// Fonction pour récupérer les jours fériés
function getHolidays($year)
{
$holidays = [
"$year-01-01", // Jour de l'An
"$year-05-01", // Fête du Travail
"$year-05-08", // Victoire 1945
"$year-07-14", // Fête Nationale
"$year-08-15", // Assomption
"$year-11-01", // Toussaint
"$year-11-11", // Armistice
"$year-12-25", // Noël
];
$easterDate = easter_date($year);
$ascension = date('Y-m-d', strtotime('+39 days', $easterDate));
$pentecost = date('Y-m-d', strtotime('+49 days', $easterDate));
$holidays[] = $ascension;
$holidays[] = $pentecost;
return $holidays;
}
// Vérifier si c'est un jour ouvré
function isBusinessDay($date, $holidays)
{
$dayOfWeek = date('N', $date); // 1 (lundi) à 7 (dimanche)
return $dayOfWeek < 6 && !in_array(date('Y-m-d', $date), $holidays);
}
// Fonction pour générer le tableau dynamique
function generateTable($startDate, $endDate)
{
setlocale(LC_TIME, 'fr_FR.UTF-8');
$currentDate = strtotime($startDate);
$endDate = strtotime($endDate);
$holidays = getHolidays(date('Y', $currentDate));
$monthColors = [
"#FFCCCC", "#FFE5CC", "#FFFFCC", "#E5FFCC", "#CCFFCC", "#CCFFE5",
"#CCFFFF", "#CCE5FF", "#CCCCFF", "#E5CCFF", "#FFCCFF", "#FFCCE5",
];
$weekOddColor = "#D6EAF8";
$weekEvenColor = "#AED6F1";
echo '<div class="custom-table-container">';
echo '<table class="table table-bordered text-center custom-table" id="dynamicTable">';
// Première ligne : en-têtes
echo '<thead><tr>';
echo '<th class="sticky-col sticky-col-1" style="width: 10px;">Date</th>';
echo '<th class="sticky-col sticky-col-2">Combo Box</th>'; // Ajouter l'en-tête pour la nouvelle colonne
echo '<th class="sticky-col sticky-col-3">Semaine</th>'; // Ajouter l'en-tête pour la nouvelle colonne
while ($currentDate <= $endDate) {
if (isBusinessDay($currentDate, $holidays)) {
$formattedDate = date('d/m/Y', $currentDate);
$formattedDate = "51";
echo '<th style="background-color: ' . $monthColors[date('n', $currentDate) - 1] . ';">' . $formattedDate . '</th>';
}
$currentDate = strtotime('+1 day', $currentDate);
}
echo '</tr>';
// Réinitialiser la date pour la deuxième ligne (numéros de semaine)
$currentDate = strtotime($startDate);
echo '<tr><td class="sticky-col sticky-col-1">Semaine</td><td class="sticky-col sticky-col-2"></td><td class="sticky-col sticky-col-3"></td>'; // Ajouter une cellule vide pour la nouvelle colonne
$lastWeekNumber = null;
$weekCellCount = 0;
while ($currentDate <= $endDate) {
if (isBusinessDay($currentDate, $holidays)) {
$weekNumber = date('W', $currentDate);
if ($weekNumber === $lastWeekNumber) {
$weekCellCount++;
} else {
if ($lastWeekNumber !== null) {
$color = ($lastWeekNumber % 2 === 0) ? $weekEvenColor : $weekOddColor;
echo '<td colspan="' . $weekCellCount . '" style="background-color: ' . $color . ';">' . $lastWeekNumber . '</td>';
}
$lastWeekNumber = $weekNumber;
$weekCellCount = 1;
}
}
$currentDate = strtotime('+1 day', $currentDate);
}
if ($lastWeekNumber !== null) {
$color = ($lastWeekNumber % 2 === 0) ? $weekEvenColor : $weekOddColor;
echo '<td colspan="' . $weekCellCount . '" style="background-color: ' . $color . ';">' . $lastWeekNumber . '</td>';
}
echo '</tr>';
// Réinitialiser la date pour la troisième ligne (jours de la semaine)
$currentDate = strtotime($startDate);
echo '<tr><td class="sticky-col sticky-col-1">Jours</td><td class="sticky-col sticky-col-2"></td><td class="sticky-col sticky-col-3"></td>'; // Ajouter une cellule vide pour la nouvelle colonne
while ($currentDate <= $endDate) {
if (isBusinessDay($currentDate, $holidays)) {
$dayName = mb_substr(ucfirst(strftime('%A', $currentDate)), 0, 3) . '.';
echo '<td style="width: 50px;">' . $dayName . '</td>';
}
$currentDate = strtotime('+1 day', $currentDate);
}
echo '</tr></thead>';
// Ajout d'une ligne vide au corps du tableau
echo '<tbody id="dataBody"></tbody>';
echo '</table>';
echo '<div class="button-container">';
echo '<button id="addRowBtn" class="btn btn-primary mt-3">Ajouter</button>';
echo '<button id="saveButton" class="btn btn-success mt-3" style="display: none;">Sauver</button>';
echo '<button id="saveToDBBtn" class="btn btn-success mt-3">BD Save</button>';
echo '<button id="loadFromDBBtn" class="btn btn-warning mt-3">DB Load</button>';
echo '<button id="SelectionBtn" class="btn btn-warning mt-3">XXX</button>';
echo '<input type="file" id="loadFileBtn" class="btn btn-info mt-3" style="display: none;" />';
echo '<button id="loadFileBtnDisplay" class="btn btn-info mt-3">Charger depuis l\'ordinateur</button>';
echo '</div>';
// Ajouter une section pour choisir un fichier sur le serveur
echo '<div class="mt-3">';
echo '<h3>Choisir un fichier depuis le serveur</h3>';
echo '<select id="serverFilesSelect" class="form-select">';
echo '<option value="">Sélectionner un fichier...</option>';
$serverFiles = getServerFiles('path/to/your/server/files'); // Remplacez par le chemin du répertoire
foreach ($serverFiles as $file) {
echo '<option value="' . $file . '">' . $file . '</option>';
}
echo '</select>';
echo '<button id="loadServerFileBtn" class="btn btn-info mt-3">Charger</button>';
echo '</div>';
echo '</div>';
}
// Fonction pour lister les fichiers dans un répertoire
function getServerFiles($directory)
{
$directory = getcwd();
$files = scandir($directory);
// Filtrer les fichiers (par exemple, uniquement les fichiers .json)
$files = array_filter($files, function($file) {
return pathinfo($file, PATHINFO_EXTENSION) === 'json';
});
return $files;
}
function aaa()
{
$host = "analogdepat.mysql.db";
$dbname = "analogdepat";
$user = "analogdepat";
$password = "Un92pac007";
$conn = new mysqli($host, $user, $password, $dbname);
// Vérifier la connexion
if ($conn->connect_error)
{
die("La connexion a échoué: " . $conn->connect_error);
}
$sql = "SELECT id FROM table_DB_planning"; // Remplacez "id" et "nom" par les colonnes de votre table
$result = $conn->query($sql);
// Vérifiez si des résultats sont retournés
if ($result->num_rows > 0) {
echo '<select name="enregistrement" id="enregistrement">';
// Afficher chaque enregistrement dans la combo box
while ($row = $result->fetch_assoc())
{
$bidule = " aaaaa ";
echo '<option value="' . $row['id'] . '">' . $row['id'] . " " . $bidule . '</option>';
}
echo '</select>';
} else {
echo "Aucun enregistrement trouvé.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tableau Dynamique</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script>
function displayJson()
{
const select = document.getElementById("comboBox");
const jsonDisplay = document.getElementById("jsonDisplay");
const selectedValue = select.value;
if (selectedValue) {
jsonDisplay.textContent = "ID de l'élément sélectionné : " + selectedValue;
} else {
jsonDisplay.textContent = "Sélectionnez un élément pour afficher son ID.";
}
if (selectedValue)
{
const xhr = new XMLHttpRequest();
xhr.open('POST', 'zoulou.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function ()
{
if (xhr.readyState === 4 && xhr.status === 200)
{
const data = JSON.parse(xhr.responseText);
alert(data);
updateTable(data);
}
};
xhr.send('id=' + encodeURIComponent(selectedValue));
}
else
{
alert("Sélectionnez un élément pour afficher son ID.");
}
}
function updateTable(data)
{
const tableBody = document.getElementById('dataBody');
tableBody.innerHTML = ''; // Vider le tableau avant de charger les nouvelles données
// Recréer le tableau avec les données chargées
data.forEach(rowData => {
const newRow = document.createElement('tr');
rowData.forEach((cellData, index) => {
const cell = document.createElement('td');
if (index === 0) {
cell.classList.add('titre_nom', 'sticky-col', 'sticky-col-1');
cell.setAttribute('contenteditable', 'true');
cell.textContent = cellData; // Remplir la première cellule avec la chaîne
} else if (index === 1) {
cell.classList.add('sticky-col', 'sticky-col-2');
const comboBox = document.createElement('select');
comboBox.classList.add('combo-box');
comboBox.innerHTML = '<option value="">Sélectionnez</option><option value="Option1">Option 1</option><option value="Option2">Option 2</option>';
comboBox.value = cellData;
cell.appendChild(comboBox);
} else {
cell.classList.add('table_date');
cell.textContent = cellData; // Remplir les autres cellules avec 0 ou 1
cell.dataset.status = cellData;
}
newRow.appendChild(cell);
});
tableBody.appendChild(newRow);
});
}
function displayJson_old() {
const select = document.getElementById("comboBox");
const jsonDisplay = document.getElementById("jsonDisplay");
const selectedValue = select.value;
if (selectedValue) {
jsonDisplay.textContent = "ID de l'élément sélectionné : " + selectedValue;
} else {
jsonDisplay.textContent = "Sélectionnez un élément pour afficher son ID.";
}
}
document.addEventListener('DOMContentLoaded', () => {
const tableBody = document.getElementById('dataBody');
const saveButton = document.getElementById('saveButton');
const loadFileBtn = document.getElementById('loadFileBtn');
const loadFileBtnDisplay = document.getElementById('loadFileBtnDisplay');
const loadServerFileBtn = document.getElementById('loadServerFileBtn');
const serverFilesSelect = document.getElementById('serverFilesSelect');
const saveToDBBtn = document.getElementById('saveToDBBtn');
const loadFromDBBtn = document.getElementById('loadFromDBBtn');
const plouf = document.getElementById('SelectionBtn');
// Ajouter une nouvelle ligne
document.getElementById('addRowBtn').addEventListener('click', () => {
const newRow = document.createElement('tr');
const firstCell = document.createElement('td');
firstCell.classList.add('titre_nom', 'sticky-col', 'sticky-col-1');
firstCell.setAttribute('contenteditable', 'true');
firstCell.textContent = 'Not define';
newRow.appendChild(firstCell);
// Ajouter une combo box dans la nouvelle colonne
const comboCell = document.createElement('td');
comboCell.classList.add('sticky-col', 'sticky-col-2');
const comboBox = document.createElement('select');
comboBox.classList.add('combo-box');
comboBox.innerHTML = '<option value="">Sélectionnez</option><option value="Option1">Option 1</option><option value="Option2">Option 2</option>';
comboCell.appendChild(comboBox);
newRow.appendChild(comboCell);
// Ajouter une cellule vide pour la troisième colonne
const thirdCell = document.createElement('td');
thirdCell.classList.add('sticky-col', 'sticky-col-3');
newRow.appendChild(thirdCell);
// Ajouter des cellules vides avec un contenu initial de 0
document.querySelectorAll('th').forEach(() => {
const cell = document.createElement('td');
cell.classList.add('table_date');
cell.textContent = '0'; // Valeur initiale de la cellule
cell.dataset.status = '0'; // Statut initial
newRow.appendChild(cell);
});
// Ajouter la nouvelle ligne au tableau
tableBody.appendChild(newRow);
saveButton.style.display = 'inline-block'; // Afficher le bouton Sauver
});
// Fermer l'édition à la touche Entrée
tableBody.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && e.target.classList.contains('titre_nom') && e.target.isContentEditable) {
e.preventDefault(); // Empêcher le saut à la ligne
e.target.blur(); // Met fin à l'édition
}
});
// Toggle des cellules de 0 à 1 et inversement
tableBody.addEventListener('click', (e) => {
if (e.target.classList.contains('table_date')) {
e.target.dataset.status = e.target.dataset.status === '0' ? '1' : '0';
e.target.textContent = e.target.dataset.status;
}
});
// Sauver les données dans un fichier JSON
saveButton.addEventListener('click', () => {
const tableData = [];
const rows = tableBody.querySelectorAll('tr');
rows.forEach(row => {
const rowData = [];
const cells = row.querySelectorAll('td');
cells.forEach((cell, index) => {
if (index === 0) {
rowData.push(cell.textContent); // Première cellule (chaîne)
} else if (index === 1) {
rowData.push(cell.querySelector('select').value); // Valeur de la combo box
} else {
rowData.push(cell.dataset.status); // Valeur de la cellule (0 ou 1)
}
});
tableData.push(rowData);
});
// Sauver les données en format JSON
const jsonData = JSON.stringify(tableData);
const blob = new Blob([jsonData], { type: 'application/json' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'tableau_data.json';
link.click();
});
// Charger les données depuis un fichier JSON (ordinateur)
loadFileBtnDisplay.addEventListener('click', () => {
loadFileBtn.click();
});
plouf.addEventListener('click', () => {
const select = document.getElementById("comboBox");
selectedValue = select.value;
console.log(selectedValue);
let data = JSON.stringify(select.value);
if (Array.isArray(data)) {
console.log("C'est un tableau !");
data.forEach(item => {
console.log(item); // Affiche chaque élément du tableau
});
} else {
console.log("Ce n'est pas un tableau.");
}
tableBody.innerHTML = ''; // Vider le tableau avant de charger les nouvelles données
// Recréer le tableau avec les données chargées
data.forEach(rowData => {
const newRow = document.createElement('tr');
rowData.forEach((cellData, index) => {
const cell = document.createElement('td');
if (index === 0) {
cell.classList.add('titre_nom', 'sticky-col', 'sticky-col-1');
cell.setAttribute('contenteditable', 'true');
cell.textContent = cellData; // Remplir la première cellule avec la chaîne
} else if (index === 1) {
cell.classList.add('sticky-col', 'sticky-col-2');
const comboBox = document.createElement('select');
comboBox.classList.add('combo-box');
comboBox.innerHTML = '<option value="">Sélectionnez</option><option value="Option1">Option 1</option><option value="Option2">Option 2</option>';
comboBox.value = cellData;
cell.appendChild(comboBox);
} else {
cell.classList.add('table_date');
cell.textContent = cellData; // Remplir les autres cellules avec 0 ou 1
cell.dataset.status = cellData;
}
newRow.appendChild(cell);
});
tableBody.appendChild(newRow);
});
alert("Youpi " + selectedValue);
});
loadFileBtn.addEventListener('change', (event) => {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
const data = JSON.parse(e.target.result);
tableBody.innerHTML = ''; // Vider le tableau avant de charger les nouvelles données
// Recréer le tableau avec les données chargées
data.forEach(rowData => {
const newRow = document.createElement('tr');
rowData.forEach((cellData, index) => {
const cell = document.createElement('td');
if (index === 0) {
cell.classList.add('titre_nom', 'sticky-col', 'sticky-col-1');
cell.setAttribute('contenteditable', 'true');
cell.textContent = cellData; // Remplir la première cellule avec la chaîne
} else if (index === 1) {
cell.classList.add('sticky-col', 'sticky-col-2');
const comboBox = document.createElement('select');
comboBox.classList.add('combo-box');
comboBox.innerHTML = '<option value="">Sélectionnez</option><option value="Option1">Option 1</option><option value="Option2">Option 2</option>';
comboBox.value = cellData;
cell.appendChild(comboBox);
} else {
cell.classList.add('table_date');
cell.textContent = cellData; // Remplir les autres cellules avec 0 ou 1
cell.dataset.status = cellData;
}
newRow.appendChild(cell);
});
tableBody.appendChild(newRow);
});
saveButton.style.display = 'inline-block'; // Afficher le bouton Sauver après le chargement
};
reader.readAsText(file);
});
// Charger un fichier depuis le serveur
loadServerFileBtn.addEventListener('click', () => {
const fileName = serverFilesSelect.value;
console.log("ffsff");
if (fileName) {
fetch(fileName)
.then(response => response.json())
.then(data => {
tableBody.innerHTML = ''; // Vider le tableau avant de charger les nouvelles données
// Recréer le tableau avec les données chargées
data.forEach(rowData => {
const newRow = document.createElement('tr');
rowData.forEach((cellData, index) => {
const cell = document.createElement('td');
if (index === 0) {
cell.classList.add('titre_nom', 'sticky-col', 'sticky-col-1');
cell.setAttribute('contenteditable', 'true');
cell.textContent = cellData; // Remplir la première cellule avec la chaîne
} else if (index === 1) {
cell.classList.add('sticky-col', 'sticky-col-2');
const comboBox = document.createElement('select');
comboBox.classList.add('combo-box');
comboBox.innerHTML = '<option value="">Sélectionnez</option><option value="Option1">Option 1</option><option value="Option2">Option 2</option>';
comboBox.value = cellData;
cell.appendChild(comboBox);
} else {
cell.classList.add('table_date');
cell.textContent = cellData; // Remplir les autres cellules avec 0 ou 1
cell.dataset.status = cellData;
}
newRow.appendChild(cell);
});
tableBody.appendChild(newRow);
});
saveButton.style.display = 'inline-block'; // Afficher le bouton Sauver après le chargement
})
.catch(error => alert('Erreur lors du chargement du fichier : ' + error));
}
});
saveToDBBtn.addEventListener('click', () => {
const tableData = [];
const rows = tableBody.querySelectorAll('tr');
rows.forEach(row => {
const rowData = [];
const cells = row.querySelectorAll('td');
cells.forEach((cell, index) => {
if (index === 0) {
rowData.push(cell.textContent); // Première cellule (chaîne)
} else if (index === 1) {
rowData.push(cell.querySelector('select').value); // Valeur de la combo box
} else {
rowData.push(cell.dataset.status); // Valeur de la cellule (0 ou 1)
}
});
tableData.push(rowData);
});
fetch('sauve_to_db.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(tableData),
})
.then(response => response.text())
.then(data => {
if (data === "OK") {
alert("Sauvegarde réussie");
} else {
alert("Erreur lors de la sauvegarde");
}
})
.catch(error => alert('Erreur : ' + error));
});
loadFromDBBtn.addEventListener('click', () => {
fetch('charge_to_db.php')
.then(response => response.json())
.then(data => {
tableBody.innerHTML = ''; // Vider le tableau avant de charger les nouvelles données
// Recréer le tableau avec les données chargées
data.forEach(rowData => {
const newRow = document.createElement('tr');
rowData.forEach((cellData, index) => {
const cell = document.createElement('td');
if (index === 0) {
cell.classList.add('titre_nom', 'sticky-col', 'sticky-col-1');
cell.setAttribute('contenteditable', 'true');
cell.textContent = cellData; // Remplir la première cellule avec la chaîne
} else if (index === 1) {
cell.classList.add('sticky-col', 'sticky-col-2');
const comboBox = document.createElement('select');
comboBox.classList.add('combo-box');
comboBox.innerHTML = '<option value="">Sélectionnez</option><option value="Option1">Option 1</option><option value="Option2">Option 2</option>';
comboBox.value = cellData;
cell.appendChild(comboBox);
} else {
cell.classList.add('table_date');
cell.textContent = cellData; // Remplir les autres cellules avec 0 ou 1
cell.dataset.status = cellData;
}
newRow.appendChild(cell);
});
tableBody.appendChild(newRow);
});
})
.catch(error => alert('Erreur : ' + error));
});
});
function getCookie(name) {
let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
return match ? match[2] : null; // Si le cookie est trouvé, on retourne sa valeur
}
</script>
<style>
.col1 {
width: 50px;
}
.col2 {
width: 200px;
}
.custom-table-container {
width: calc(100% - 100px); /* 100% de la largeur moins 100px pour les marges */
margin: 0 auto; /* Centre le conteneur horizontalement */
padding: 0 50px; /* Ajoute 50px de marge à gauche et à droite */
box-sizing: border-box; /* Inclut les marges dans la largeur totale */
overflow-x: auto; /* Ajoute une barre de défilement horizontale si nécessaire */
}
.custom-table {
width: 100%; /* Assurez-vous que le tableau prend toute la largeur du conteneur */
margin: 0 auto; /* Centre le tableau horizontalement */
}
.custom-table th:first-child,
.custom-table td:first-child {
width: 20px; /* Largeur de la première colonne */
}
.custom-table th:not(:first-child),
.custom-table td:not(:first-child) {
width: 10px; /* Largeur des autres colonnes */
}
.table_date[data-status="1"] {
background-color: #007BFF;
color: #fff;
}
.titre_nom[contenteditable="true"] {
border: 1px dashed #000;
padding: 5px;
white-space: nowrap; /* Empêche le retour à la ligne */
overflow: hidden; /* Cache tout excédent de texte qui dépasse */
}
.button-container {
display: flex;
gap: 50px; /* Ajoute un espacement de 50px entre les boutons */
}
.button-container button {
margin-right: 50px; /* Optionnel, si vous voulez ajouter un peu de marge sur la droite de chaque bouton */
}
.sticky-col {
position: -webkit-sticky; /* Pour Safari */
position: sticky;
left: 0;
background-color: white; /* Pour rendre le fond blanc et éviter le chevauchement */
z-index: 1; /* Pour s'assurer que les colonnes sticky sont au-dessus des autres */
}
.sticky-col-1 {
left: 0;
}
.sticky-col-2 {
left: 10px; /* Ajustez cette valeur en fonction de la largeur de la première colonne */
}
.sticky-col-3 {
left: 110px; /* Ajustez cette valeur en fonction de la largeur des deux premières colonnes */
}
</style>
</head>
<body>
<h1>Combobox avec affichage des données</h1>
<label for="comboBox">Choisissez un titre :</label>
<select id="comboBox" onchange="displayJson()">
<option value="">-- Sélectionnez --</option>
<?php foreach ($entries as $entry): ?>
<option value="<?= htmlspecialchars($entry['id']) ?>">
<?= htmlspecialchars($entry['id']) ?>
</option>
<?php endforeach; ?>
</select>
<h2>Données associées</h2>
<pre id="jsonDisplay">Sélectionnez un élément pour afficher son ID.</pre>
<!-- Boîte modale -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Message d'information</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="modalBody">
<!-- Le texte dynamique sera inséré ici -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<?php generateTable('2025-01-01', '2025-12-31'); ?>
<form method="POST" action="selection_sauvegarde.php">
<label for="enregistrement">Choisir un enregistrement:</label>
<?php
// Insérez ici le code PHP pour afficher la combo box
$host = "analogdepat.mysql.db";
$dbname = "analogdepat";
$user = "analogdepat";
$password = "Un92pac007";
$conn = new mysqli($host, $user, $password, $dbname);
// Vérifier la connexion
if ($conn->connect_error)
{
die("La connexion a échoué: " . $conn->connect_error);
}
$sql = "SELECT id FROM table_DB_planning"; // Remplacez "id" et "nom" par les colonnes de votre table
$result = $conn->query($sql);
// Vérifiez si des résultats sont retournés
if ($result->num_rows > 0) {
echo '<select name="enregistrement" id="enregistrement">';
// Afficher chaque enregistrement dans la combo box
while ($row = $result->fetch_assoc())
{
$bidule = " aaaaa ";
echo '<option value="' . $row['id'] . '">' . $row['id'] . " " . $bidule . '</option>';
}
echo '</select>';
} else {
echo "Aucun enregistrement trouvé.";
}
?>
<input type="submit" value="Consulter">
</form>
</div>
</body>
</html>