Mysql
 sql >> Database >  >> RDS >> Mysql

Visualizzazione dei valori a discesa separati da virgole dalla colonna nel database

Prova a usare questo, se necessario, program valori di colonna :

<?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>';
?>