sql >> Database >  >> RDS >> Mysql

Door komma's gescheiden dropdown-waarden van kolom in database weergeven

Probeer dit, indien nodig, program . te gebruiken kolomwaarden :

<?php
$pdo = Database::connect();
$sql="SELECT t1.*, t2.*
    FROM form_fields t1, user_choices t2
    WHERE t1.field_name = t2.field_name
    and group_id=1 and user_id=".$_SESSION['user_id']." ";
//$result = $pdo->query($sql);

echo '<select class="form-control" name="program">';
foreach ($pdo->query($sql) as $row_program){
    $options = $row_program['program'];// as you need this column values
    $optionsArr = explode(",", $options);   
    foreach ($optionsArr as $key=>$row){
        echo '<option value='.$row[$key].'>'.$row[$key].'</option>'; 
    }
}
echo '</select>';
?>


  1. controleer op geldige datum die is aangegeven in varchar2

  2. Kan Hibernate werken met de ON DUPLICATE KEY UPDATE-syntaxis van MySQL?

  3. Query om buitenlandse sleutels te vinden

  4. Liquibase-updatefout