lundi 14 mars 2016

How to post a checkbox value with database content in it? PHP&MYSQL

I got the following issue. I want to set a value from a database query to a checkbox value and then post the checkbox value to another file.

   $sql = "SELECT * FROM Kunde  WHERE UserID = $UserID";
        foreach ($db->query($sql) as $zeile)
        {                                   
                echo "<tr>";
                //echo "<td>"; echo $zeile['id']; echo "</td>";
                echo "<td>"; echo $zeile['Name']; echo "</td>";
                echo "<td>"; echo $zeile['Vorname']; echo "</td>";
                echo "<td>"; echo $zeile['Strasse']; echo "</td>";
                echo "<td>"; echo $zeile['PLZ']; echo "</td>";
                echo "<td>"; echo $zeile['Ort']; echo "</td>";
                echo "<td>"; echo $zeile['Rufnummer']; echo "</td>";
                echo "<td>"; echo $zeile['Email']; echo "</td>";
                echo "<td>"; echo $zeile['Datum']; echo "</td>";
                echo "<td>"; echo $zeile['Verlauf']; echo "</td>";
                echo "<form action='update.php' method='post'>";
                $id = $zeile['id'];
                echo "<td>"; echo "<label>"; echo '<input type="checkbox" name="edit" value="'; echo $id; echo '"/>'; echo "</label>"; echo "</td>";
                echo "<td>"; echo "<label>"; echo '<input type="checkbox" name="delete">'; echo "</label>"; echo "</td>";
                echo "<td>"; echo "<button type='submit' class='submit'>Submit</button>"; echo "</td>";

Is this even possible? I also tried

echo '<input type="checkbox" name="edit" value="'; echo $zeile['id']; echo '"/>';

but without success. Any ideas to manage this would be great. THX




Aucun commentaire:

Enregistrer un commentaire