Ich habe ein Problem mit einem script das ich gefunden habe und bearbeitet habe.
Es soll als erstes alle datensätze auslesen (tut es), dann soll man mehrere Datensätze per Checkbox auswählen und anzeigen (geht auch)
Nur das bearbeiten (Beispiel die Variable $post_id ausgeben funktioniert nicht
Vielleicht könnt ihr mir helfen?
ueber.php
PHP
- <html>
- <head>
- <?php
- //Zur Datenbank verbinden
- $conn = mysqli_connect("localhost", "root","","cms");
- // Datensaetze abrufen
- $query = "SELECT * FROM posts ORDER BY post_id ASC";
- $result = mysqli_query($conn,$query);
- if (mysqli_num_rows($result) > 0) {
- ?>
- <form action="drucken.php" method="post">
- <table>
- <tr>
- <th></th>
- <th>ID</th>
- <th>Name</th>
- <th>Kategorie</th>
- <th>Stichworte</th>
- </tr>
- <?php
- while ($row = mysqli_fetch_assoc($result)) {
- ?>
- <tr>
- <td><input name="print[]" type="checkbox" value="<?php print $row["post_id"]; ?>" /></td>
- <td><?php print $row["post_id"]; ?></td>
- <td><?php print $row["post_title"]; ?></td>
- <td><?php print $row["post_status"]; ?></td>
- <td><?php print $row["post_tags"]; ?></td>
- </tr>
- <?php
- }
- ?>
- <tr>
- <td colspan="6"><input name="weiter" type="submit" value="Weiter" />
- </tr>
- </table>
- </form>
- <?php
- }
- ?>
drucken.php
PHP
- <?php
- if (isset($_POST['submit'])) {
- $post_id = $_POST['post_id'];
- echo $post_id; //Gibt leider die Variable nach absenden nicht aus
- }
- $conn = mysqli_connect("localhost", "root","","cms");
- if (isset($_POST["weiter"])) {
- foreach ($_POST["print"] as $key => $value) {
- $query = "SELECT * FROM `posts` WHERE `post_id` = '". $value ."'";
- $stmt = mysqli_query($conn, $query);
- $row = mysqli_fetch_assoc($stmt);
- ?>
- <td><form method="POST"></td><br>
- <td><input disabled="disabled" type="text" name="post_id" value="<?php print $row["post_id"]; ?>"></td></td><br>
- <td><input type="text" name="post_title" value="<?php print $row["post_title"]; ?>"></td></td><br>
- <td><input type="text" name="post_status" value="<?php print $row["post_status"]; ?>"></td></td><br>
- <td><input type="text" name="post_tags" value="<?php print $row["post_tags"]; ?>"></td><br>
- <td><input type="submit" value="Speichern" name="submit"></td><br>
- <td></form></td><br><br>
- <?php }
- }
- ?>
Habt ihr eine Idee?