Codeaur Codeaur - 1 year ago 63
PHP Question

Trying to make a dynamic dropdown in php from database

I got a little question I want to make a dropdown menu from the data I get from the database.
I will get the following data

$starttime = 12:00:00
$endtime = 14:00:00
$talktime = 00:30:00

now I want to make a dropdown menu from it that it loops.
here is my example how I thought it would work.

for ($endtime = $starttime + $talktime){}

But as the code works I want to check the database if the data already exist. I know how to do that part only the loop I don't know.

Already thank you for the help.

Answer Source

You can try this

$starttime = new DateTime("12:00:00");
$endtime = new DateTime("14:00:00");
<select name="" id="input" class="form-control" required="required">
while($starttime <= $endtime)

    echo "<option value='".$starttime->format('H:i:s')."'>".$starttime->format('H:i:s')."</option>";

    $starttime = date_add($starttime, date_interval_create_from_date_string('30 min'));
echo " </select>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download