sql - Display data from database using explode in php -


i have table named "test". retrieve data 1 column. each row have multiple data separate coma. how can display data of column in drop-down?

id | qualification 1  | be,phd,me 2  | mca,mba 3  | mba 

how can display data of qualification column in dropdown? output should following

be phd me mca mba mba 

loop throught rows , create array of each row exploding rule. merge arrays together. this:

//example data todo: replace table data $rows[0]['qualification'] = 'a,b,c';  $rows[1]['qualification'] = 'a,b,c';   $qualificationarray = array(); foreach($rows $rowdata) {     $rowdataarray = explode(',',$rowdata['qualification']);     $qualificationarray = array_merge($qualificationarray,$rowdataarray); } 

then use qualificationarray create dropdown

echo '<select name="qualification">'; foreach($qualificationarray $qualification) {     echo '<option value="'.$qualification.'">'.$qualification.'</option>'; } echo '</select>'; 

so output of dropdown of every value:

<select name="qualification">     <option value="a">a</option>     <option value="b">b</option>     <option value="c">c</option>     <option value="a">a</option>     <option value="b">b</option>     <option value="c">c</option> </select>    

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -