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
You cannot set the value of a checkbox, but you can have a hidden input that holds a value for the checkbox.
<input type='checkbox' name='myCheckbox' />
<input type='hidden' name='myCheckbox_data' value='<?= $data ?>' />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.