Advertisement
noam76

manage the cash

May 10th, 2023 (edited)
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.95 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <title>Gestion de la caisse des appartements</title>
  4. </head>
  5. <body>
  6.     <h1>Gestion de la caisse des appartements</h1>
  7. <!-- Tableau d'affichage des entrées/sorties -->
  8. <h2>Tableau d'affichage des entrées/sorties</h2>
  9. <table border="1">
  10.     <tr>
  11.         <th>Date</th>
  12.         <th>Numéro d'appartement</th>
  13.         <th>Nom du locataire</th>
  14.         <th>Service</th>
  15.         <th>Montant</th>
  16.         <th>Moyen de paiement</th>
  17.         <th>Type (Entrée/Sortie)</th>
  18.     </tr>
  19.     <?php
  20.         // Define database credentials
  21.         $servername = "localhost";
  22.         $username = "your_username";
  23.         $password = "your_password";
  24.         $dbname = "your_database_name";
  25.  
  26.         // Create a connection to the database
  27.         $conn = new mysqli($servername, $username, $password, $dbname);
  28.  
  29.         // Check if the connection is successful
  30.         if ($conn->connect_error) {
  31.             die("Connection failed: " . $conn->connect_error);
  32.         }
  33.  
  34.         // Retrieve all the entries from the table 'caisse'
  35.         $sql_select = "SELECT * FROM caisse";
  36.         $result_select = $conn->query($sql_select);
  37.  
  38.         if ($result_select->num_rows > 0) {
  39.             // Output each row of the table 'caisse'
  40.             while($row = $result_select->fetch_assoc()) {
  41.                 echo "<tr><td>" . $row["date"] . "</td><td>" . $row["numero_appart"] . "</td><td>" . $row["nom_locataire"] . "</td><td>" . $row["service"] . "</td><td>" . $row["montant"] . "</td><td>" . $row["moyen_paiement"] . "</td><td>" . $row["type"] . "</td></tr>";
  42.             }
  43.         } else {
  44.             echo "<tr><td colspan='7'>Il n'y a aucune entrée/sortie dans la caisse pour le moment.</td></tr>";
  45.         }
  46.  
  47.         // Close the database connection
  48.         $conn->close();
  49.     ?>
  50. </table>
  51.  
  52. <!-- Formulaire d'ajout d'entrée/sortie -->
  53. <h2>Ajouter une entrée/sortie</h2>
  54. <form method="post">
  55.     <label for="type">Type :</label>
  56.     <select name="type" id="type">
  57.         <option value="Entree">Entrée</option>
  58.         <option value="Sortie">Sortie</option>
  59.     </select><br><br>
  60.  
  61.     <label for="numero_appart">Numéro d'appartement :</label>
  62.     <select name="numero_appart" id="numero_appart">
  63.         <?php
  64.             // Create a connection to the database
  65.             $conn = new mysqli($servername, $username, $password, $dbname);
  66.  
  67.             // Check if the connection is successful
  68.             if ($conn->connect_error) {
  69.                 die("Connection failed: " . $conn->connect_error);
  70.             }
  71.  
  72.             // Retrieve all the entries from the table 'appartements'
  73.             $sql_select = "SELECT * FROM appartements";
  74.             $result_select = $conn->query($sql_select);
  75.  
  76.             if ($result) {
  77. $row = mysqli_fetch_assoc($result);
  78. $nom = $row['nom'];
  79. $prenom = $row['prenom'];
  80. echo "Nom : $nom<br>";
  81. echo "Prénom : $prenom<br>";
  82. } else {
  83. echo "Aucun locataire trouvé pour cet appartement.";
  84. }
  85. }
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement