I have tried this code code link. But the result shows only the last value of column. I want to show all the values of column in select tag with choosing purpose. How to get proper value?
Avoid writing so much PHP code within the option
tag. Write the database fetch code before and store it in array.
Later on, just loop through this $array
.
<?php
$dbc = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
$query = "SELECT id FROM done_add";
$data = mysqli_query($dbc, $query);
$array=[];
while ($row = mysqli_fetch_array($data)) {
$array[] = $row['id'];
}
?>
<select name="selectlink">
<?php foreach ($array as $arr) { ?>
<option value = ""> <?php print($arr); ?></option>
<?php } ?>
</select>