$driversList = "<option value='0'>Choose...</option>";
$query = $db_con->prepare( "SELECT driverId, nameSurname, plate FROM tbdrivers WHERE place=? AND state=1" );
$drivers = $query->fetchAll([$place]);
foreach ( $drivers as $driver ) {
$driversList += "<option value='$driver[0]'>$driver[1] - $driver[2]</option>";
}
echo json_encode( [ "ok" => true, "driversList" => $driversList ] );
What's wrong? In MVC design pattern it's better dont use PHP code (controller) in your HTML (view). BTW if we forget MVC ,I don't understand why you think you can't do it?
you should use mvc pattern , it very basic and clear
Обсуждают сегодня