Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <title>Benutzer Aktivität</title>
  4.     <meta charset="utf-8" />
  5. </head>
  6.  
  7. <body>
  8.  
  9. <?php
  10. include("Parametres.php");
  11.  
  12. // Connecting to the MySQL server
  13. $mysqli=mysqli_connect($host,$user,$pass) or die("Problem of connection to the MySQL server :".mysqli_error());
  14.    
  15. // Creating the database
  16. //query($mysqli,'CREATE DATABASE IF NOT EXISTS '.$base);
  17.    
  18. // Selecting the database
  19. mysqli_select_db($mysqli,$base) or die("Selection of the database failed! : $base");
  20.  
  21. //Darstellung der Zutaten Tabelle für die Auswahl
  22. //Auswahl Zutaten aus Kategorie? ("obst_gemüse","alkohol","saft_sirup","sonstige")
  23. //Speichern in der Datenbank als neue/eigene Cocktail
  24.  
  25.  
  26. # execute search query
  27. $query = 'SELECT * FROM `DetailsCategory`';
  28. $result = mysqli_query($mysqli, $query);
  29.  
  30. # check result
  31. if (!$result)
  32.     die('Could not successfully run query: ' . mysqli_connect_error());
  33.  
  34. # display returned data
  35. if (mysqli_num_rows($result) > 0)
  36. {
  37.     ?>
  38.     <form action="" method="post">
  39.     <table border = "1" align = "center" style="line-height:25px;">
  40.     <tr>
  41.         <th>Auswahl</th>
  42.         <th>Id</th>
  43.         <th>Obst/Gemuese</th>
  44.         <th>Alkohol</th>
  45.         <th>Saft/Sirup</th>
  46.         <th>Sonstige</th>
  47.         <th>Datum</th>
  48.  
  49.         <?php
  50.             while ($row = mysqli_fetch_assoc($result))
  51.             {
  52.                 echo '<tr><td>';
  53.                 echo '<input type="checkbox" name="selected[]" value="'.$row['id'].': '.$row['obst_gemuese'].', '.$row['alkohol'].', '.$row['saft_sirup'].', '.$row['sonstige'].'"/>';
  54.                 echo '</td>';
  55.                 foreach ($row as $key => $value)
  56.                     echo '<td>'.htmlspecialchars($value).'</td>';
  57.                 echo '</tr>';
  58.             }
  59.         ?>
  60.     </table>
  61.  <!--     <input type="submit"/>  -->
  62.     <input type = "submit" name = "submit" value = "Submit" />
  63.    
  64. <?php
  65. if(isset($_POST['submit'])){
  66.    
  67.     if(!empty($_POST['selected'])) {
  68.        
  69.         // Counting number of checked checkboxes.
  70.         $checked_count = count($_POST['selected']);
  71.    
  72.         echo "Sie haben folgende ".$checked_count." Zutaten(s) ausgewählt: <br/>";
  73.    
  74.         // Loop to store and display values of individual checked checkbox.
  75.         foreach($_POST['selected'] as $selected) {
  76.             echo "<p>".$selected ."</p>";
  77.         }
  78.  
  79.     }
  80.  
  81. }
  82. ?>
  83.     </form>
  84.     <?php
  85.  
  86. }
  87. else
  88.     echo '<p>No data</p>';
  89.  
  90. # free resources
  91. mysqli_free_result($result);
  92.  
  93. ?>
  94.  
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement