So I have this database
and it has column called selectedDates
. In that column there is a row with the values
2018-08-22
2018-08-15
2018-08-20
Keep in mind this is 3 sets of dates, but in one row. How do I make a select tag/dropdown with these three values. Is this possible to do? If more information is needed, let me know and I will edit.
Down below is my code for having it do a dropdown of options within one column, but different rows. Such as
Column 1
Row 1 - Dog
Row 2 - Cat
Row 3 - Mouse
I need it to be like
Column 1
Row 1 - Dog,Cat,Mouse
and then have the dropdown options as dog cat mouse
example code below of column 1, 3 different rows
<?php
$con = new mysqli('localhost', 'root', '', 'races');
if($con->connect_errno) {
// error reporting here
}
$result = $con->query("SHOW TABLES");
if($result->num_rows > 0) {
echo '<select id="myTable" onchange="myFunction()">';
while($row = $result->fetch_array(MYSQLI_NUM)) {
echo '<option value="Test" name="SelectedDate">' . $row[0] . '</option>';
}
echo '</select>';
} ?>
edit for replying to comment Example database
Id | Info | SelectedDates
1 hi 2018-18,2018-19
2 hi 2018-20,2018-21
In the code you provided, in my example it would only create a dropdown with id 1, but if I had another row like id 2, can i change $row[0]
to $row[1]
to have my dropdown display the 2nd row of selected dates?