'HTML PHP, how do i set the value of a radio button thats made with a while loop
I have radio buttons that are made from a while loop thats gotten from my database
basically i have an edit page for it but i cant seem to get the value from the database and set it in the radio button.
i want it so that the radio button thats been checked would appear
<?php $stmt = $db->prepare("SELECT dishname FROM dishes WHERE category = 'Pasta'AND package = {$packageid}");
$stmt->execute();
$stmt->bind_result($pasta);
while($stmt->fetch()): ?>
<input type ='radio' class = 'ds' id = 'pasta' value ='<?php echo $pasta ?>' name = 'pasta' required>
<label for = 'pasta'><?php echo $pasta; ?></label>
<?php endwhile; $stmt->close();?>```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
